Prototype 1.7 - 属性选择器坏了?
我最近从 Prototype 1.6.1 升级到 1.7,我注意到我网站的 JS 的一部分被破坏了。
我本质上是这样做的:
$$("*[required=1]").each(function (el) {
// stuff
});
这是选择一堆表单元素。在 1.6.1 中,这工作得很好。自从我升级到 1.7 以来,这不仅返回表单中的 ...
我知道 Prototype 发生了变化从他们旧的选择器引擎到 1.7 中的 Sizzle,所以我假设它与此有关,但我很惊讶这个基本的东西会破坏......
我使用了错误的语法吗?知道如何解决这个问题而不降级到 1.6 吗?
I recently upgraded from Prototype 1.6.1 to 1.7, and I noticed that a part of my site's JS got broken.
I'm esentially doing this:
$("*[required=1]").each(function (el) {
// stuff
});
This is selecting a bunch of form elements. In 1.6.1, this worked perfectly. Since I upgraded to 1.7, this not only returns the <select>
elements in my form, but not the <input>
s...
I know that Prototype changed from their old selector engine to Sizzle in 1.7, so I'm assuming it has to do with that, but I'm surprised something this basic would break...
Am I using the wrong syntax? Any idea how I can work around this, without downgrading to 1.6?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,我尝试了一下,通过在属性值周围添加单引号来解决这个问题,但是根据 CSS 选择器规范,这似乎是错误的,对吗?
特别是因为它返回的是选择的内容,而不是输入的内容......
只是发布此内容以防有人偶然发现同样的事情。
Ok, experimenting a bit I got around it, by adding single quotes around the attribute value, but this seems wrong based on the CSS selectors spec, right?
Especially since it IS returning select's, but not input's....
Just posting this in case someone stumbles upon the same thing.