我刚刚发现一些使用 .setAttributeNode
的旧 JavaScript 代码已损坏。
Internet Explorer(在 IE10 中测试)给出错误(未知属性),而 FireFox 警告它已被弃用。
RienNeVaPlu͢s 向我指出了文档,其中显示 DOM Level 4 Core 已删除 .setAttributeNode
along with a bunch of other methods .
我尝试搜索有关 MS 何时以及为何放弃 DOM Level 3 Core 兼容性的文档。检查最新补丁后,我认为它与MS15-009有关。补丁于 2015 年 2 月 10 日发布,但我尚未确认。
任何人都可以确认是否全部 deprecated methods已被删除还是只是其中一些?
以下是可能受影响的方法列表:
接口(interface)成员:
节点
hasAttributes()
attributes
namespaceURI
prefix
localName
isSupported
getFeature()
getUserData()
setUserData()
isSameNode()
文档
createCDATASection()
createAttribute()
createAttributeNS()
createEntityReference()
inputEncoding
xmlEncoding
xmlStandalone
xmlVersion
strictErrorChecking
domConfig
normalizeDocument()
renameNode()
DOMI实现
getFeature()
属性
No longer inherits from Node and therefore completely changed.
元素
getAttributeNode()
getAttributeNodeNS()
setAttributeNode()
removeAttributeNode()
schemaTypeInfo
setIdAttribute()
setIdAttributeNS()
setIdAttributeNode()
文档类型
entities
notations
internalSubset
文字
isElementContentWhitespace
replaceWholeText()
更新:
我进行了更多测试,发现旧式事件也不起作用。
更新2:
我已经在 IE10 和 IE11 上进行了测试,行为是相同的,它们似乎都遵循 DOM Level 4 Core。 您可以通过激活浏览器中的兼容模式(模拟 IE7)来恢复到较旧的 DOM 级别,但这也意味着新功能不可用。
最佳答案
似乎所有主流浏览器都在 2015 年初切换到 W3C DOM 4。
为了兼容,您需要在网站上使用新的 DOM 结构。
使用 Internet Explorer 浏览的用户可以启用兼容模式
来模拟 IE7 并使用 DOM 3(在 IE10 和 IE11 上测试)。
关于javascript - IE 中的 DOM Level 2 和 3 核心支持?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28673735/