javascript - IE 中的 DOM Level 2 和 3 核心支持?

标签 javascript internet-explorer dom

我刚刚发现一些使用 .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/

相关文章:

javascript - 为 angular-materialize 添加依赖项时出错

javascript - 如何使用默认按钮来关闭tippyjs的工具提示

javascript - DOM 渲染是否保证在单个(同步)函数执行期间阻塞?

javascript - 消除相对定位的 div 的水平滚动

javascript - 是否可以通过某种方式将 JSON 对象直接存储到 DOM 中?

javascript - 使用jsonp将数据发送到远程服务器

javascript - Elasticsearch 在 Jasmine 测试中没有按时索引

javascript - 在 IE9-10 中使用 sort() 问题对 DOM 元素进行排序

javascript - 为什么 .filter() 在 Internet Explorer 8 中不起作用?

javascript - 通过 Webpack 5 构建后,应用程序在 Internet Explorer (IE11) 上停止工作