jquery 错误使用 removeProp() 时迁移插件没有警告
No warning from jquery Migrate plug-in when using removeProp() incorrectly
在我解释这个问题之前,让我告诉你我清楚地知道 jQuery removeProp 不应该用于本机属性,例如禁用、选中和选中。 https://api.jquery.com/removeProp/
我们将 jQuery 从 1.12.3 升级到 3.6.0。我们使用 JQuery 迁移插件来识别兼容性问题并修复控制台中生成的所有警告。
$(“#x”).removeProp(“disabled”)
在 1.12.3 中工作,升级到最新版本后停止工作。但除非我们手动测试页面,否则我们无法确定问题所在。我想知道为什么 jQuery 迁移插件没有给我们关于相同的警告。
我知道我们之前用错了,我们很乐意将其更正为$(“#x”).prop(“disabled”,false)
这是来自 jQuery 核心团队的 Timmy Willison 在此错误报告中的解释 https://github.com/jquery/jquery/issues/4887
I think this is just a docs issue. We should change that to say "This
can remove the property completely or have no effect at all." I
followed the code and it's just calling delete, which is the right
thing. 1.x used to set properties to undefined for old IE, which is no
longer necessary and technically invalid.
That said, this is somewhat moot. The reason needs updating, but the
recommendation remains valid. There's no reason you should need to
remove a native property (nor should you expect that to work–Blink is
making it impossible anyway). It's not the same as removing a content
attribute, which would actually set the corresponding property to
false. Setting to false is the right thing here.
提出的问题导致 .removeProp()
的文档发生变化。 https://github.com/jquery/api.jquery.com/pull/1189
在我解释这个问题之前,让我告诉你我清楚地知道 jQuery removeProp 不应该用于本机属性,例如禁用、选中和选中。 https://api.jquery.com/removeProp/
我们将 jQuery 从 1.12.3 升级到 3.6.0。我们使用 JQuery 迁移插件来识别兼容性问题并修复控制台中生成的所有警告。
$(“#x”).removeProp(“disabled”)
在 1.12.3 中工作,升级到最新版本后停止工作。但除非我们手动测试页面,否则我们无法确定问题所在。我想知道为什么 jQuery 迁移插件没有给我们关于相同的警告。
我知道我们之前用错了,我们很乐意将其更正为$(“#x”).prop(“disabled”,false)
这是来自 jQuery 核心团队的 Timmy Willison 在此错误报告中的解释 https://github.com/jquery/jquery/issues/4887
I think this is just a docs issue. We should change that to say "This can remove the property completely or have no effect at all." I followed the code and it's just calling delete, which is the right thing. 1.x used to set properties to undefined for old IE, which is no longer necessary and technically invalid.
That said, this is somewhat moot. The reason needs updating, but the recommendation remains valid. There's no reason you should need to remove a native property (nor should you expect that to work–Blink is making it impossible anyway). It's not the same as removing a content attribute, which would actually set the corresponding property to false. Setting to false is the right thing here.
提出的问题导致 .removeProp()
的文档发生变化。 https://github.com/jquery/api.jquery.com/pull/1189