本文介绍了为什么document.implementation.hasFeature()总是返回true?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I found a weird problem: whatever parameters passed to the hasFeature function, it always returns true.

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

任何人都可以告诉我为什么hasFeature( )函数无法正常工作?

Can anyone pls tell me why the hasFeature() function does not work properly?

推荐答案

来自MDN:

From MDN: DOMImplementation.hasFeature()

不同的实现在报告的功能类型方面存在很大差异。该规范的最新版本已经确定强制此方法始终返回true,其中功能是准确的并且正在使用中。

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.

这篇关于为什么document.implementation.hasFeature()总是返回true?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 01:04