IE:未记录的“缓存”为输入元素定义属性?
我在 IE(6/7/8) 中偶然发现了一种奇怪的行为,这让我抓狂。给定以下标记:
<input type="text" value="foo" class="bar" cache="yes" send="no" />
请注意,cache
属性设置为 yes
。然而,IE 在渲染 DOM 时设法将属性值更改为 cache="cache"
。
所以,我想知道,是否有一个我不知道的未记录的功能?我已经用谷歌搜索了大约一个小时,但找不到任何相关信息(甚至在 MSDN 上也没有)。
注意
我知道添加自定义属性不符合标准,布尔属性应标记为 attribute="attribute"
。尽管如此,我必须应对这些问题,因为它们是在我加入团队之前很久就引入的。这些自定义属性与 javascript 结合使用,以提供更加用户友好的表单处理方法(并且在 Firefox/Safari/Opera/Chrome 上运行得很好)。
我知道我可以简单地将这些自定义属性转换为将在 HTML5 中引入的 x-data 属性,但这将花费我几个小时的额外工作 - 叹息。
希望,我已经说清楚了。 提前致谢。
I've stumpled upon a strange behavior in IE(6/7/8) that drives me nuts. Given the following markup:
<input type="text" value="foo" class="bar" cache="yes" send="no" />
Please note that the cache
attribute is set to yes
. However IE somehow manages to change the attributes value to cache="cache"
when rendering the DOM.
So, I wonder, is there an undocumented feature that I'm not aware of? I've googled about an hour now but couldn't find any info on this (not even on MSDN).
NOTE
I'm aware that adding custom attributes is non-standard compliant and that boolean attributes should be noted as attribute="attribute"
. Nevertheless I have to cope with these as they were introduced long before I joined the team. These custom attributes are used in conjunction with javascript to provide a more user friendly approach to form handling (and it works out quite well with Firefox/Safari/Opera/Chrome).
I know that I could simply convert these custom attributes to x-data attributes that will be introduced with HTML5 but that would take me several hours of extra work - sigh.
Hope, I made myself clear.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
多年来,布尔属性最好写成
等。这是因为在恐龙时代,你应该仅编写
并分配与属性名称相同的值会破坏最少的旧版浏览器,同时仍使标记符合 XML 标准。
For ages, it has been that boolean attributes are preferrably written as
<input type="checkbox" checked="checked"/>
etc. This is because in the dinosaur age, you were supposed to only write<input type="checkbox" checked/>
and assigning the same value as the property name broke the fewest legacy browsers, while still making the markup XML-compliant.