gpt4 book ai didi

javascript - 为什么 document.implementation.hasFeature() 总是返回 true?

转载 作者:数据小太阳 更新时间:2023-10-29 06:09:58 25 4
gpt4 key购买 nike

我发现了一个奇怪的问题:无论传递给 hasFeature 函数的参数是什么,它总是返回 true。

console.log(document.implementation.hasFeature('HTML', '2.0'));//return true
console.log(document.implementation.hasFeature('fake', '9.0'));//return true

谁能告诉我为什么 hasFeature() 函数不能正常工作?

最佳答案

来自 MDN:DOMImplementation.hasFeature()

The DOMImplementation.hasFeature() method returns a Boolean flag indicating if a given feature is supported. It is deprecated and modern browsers return true in all cases.

The different implementations fairly diverged in what kind of features were reported. The latest version of the spec settled to force this method to always return true, where the functionality was accurate and in use.

关于javascript - 为什么 document.implementation.hasFeature() 总是返回 true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43317691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com