为什么document.implementation.hasFeature()总是返回true? [英] Why document.implementation.hasFeature() always return true?

查看:75
本文介绍了为什么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: DOMImplementation.hasFeature()

From MDN: DOMImplementation.hasFeature()


DOMImplementation.hasFeature()方法返回一个布尔标志,指示是否支持给定的功能。它已被弃用,现代浏览器在所有情况下都返回true。

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.

不同的实现在报告的功能类型方面存在很大差异。该规范的最新版本已经确定强制此方法始终返回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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆