Firefox上的document.domConfig有什么用? [英] What's up with document.domConfig on Firefox?

查看:186
本文介绍了Firefox上的document.domConfig有什么用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我遇到一个有趣的现象在Firefox,文件声称支持时,我正在迭代文档的属性属性 domConfig 虽然 MDC说没有实现,但是当我尝试检索属性时,我会收到一个例外:


错误:未捕获异常:[异常...组件返回的故障代码:0x80004001(NS_ERROR_NOT_IMPLEMENTED)[nsIDOM3Document.domConfig]nsresult:0x80004001(NS_ERROR_NOT_IMPLEMENTED)位置:JS frame :: javascript:alert(typeof(document.domConfig)):: :: line 1数据:否]


以下显示的行为,Chrome和IE都是一致的(我没有检查过Opera)说, domConfig 不是窗口的属性,但Firefox声称它是但是无法检索它(从粘贴到URL字段,因为我可以

  / *在FF中为true,在其他浏览器中为false * / 
javascript :alert(文件中的domConfig)
/ *在FF中的异常,其他浏览器中的'undefined'* /
javascript:alert(typeof(document.domConfig))

这里发生了什么?

解决方案

Pointy的权利, domConfig 在界面中公开(DOM Level 3 Core 文档 - 在Mozilla的来源中,它被称为 nsIDOM3Document ),但是未实现(见 nsDocument :: GetDomConfig())。 typeof 首先得到值,然后确定它的类型(而不是从接口定义),所以这并不奇怪 typeof document.domConfig 抛出异常。



至于为什么这样做,该代码添加的错误没有任何讨论,所以我们只能猜到。



我的猜测是,为了规范Mozilla旨在实现它是有意义的,以完成(冻结Mozilla的术语)接口,以便它们可以从二进制代码使用,而不需要进一步修改后,界面的新属性/方法实施了而且这似乎并不重要。



如果您有兴趣从开发者那里听到,您可以在 mozilla.dev.tech.dom 或mozilla.dev.platform。


I was iterating over properties of document when I ran into an interesting phenomena in Firefox, document claims to support the property domConfig although MDC says it isn't implemented but when I try to retrieve the property I get an exception:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIDOM3Document.domConfig]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: javascript:alert(typeof(document.domConfig)) :: :: line 1" data: no]

The following shows the behaviour, both Chrome and IE are consistent (I haven't checked Opera) in saying that domConfig is not a property of window but Firefox claims it is but can't retrieve it (copy paste into URL field since I can't get markdown to give a link).

/* true in FF, false in other browsers */ 
javascript:alert("domConfig" in document)
/* exception in FF, 'undefined' in other browsers */
javascript:alert(typeof(document.domConfig)) 

What's going on here?

解决方案

Pointy's right, domConfig is exposed in an interface (DOM Level 3 Core Document - in Mozilla's source it's called nsIDOM3Document), but is not implemented (see nsDocument::GetDomConfig()). typeof works by first getting the value, then determining its type (and not from the interface definition), so it's not surprising typeof document.domConfig throws an exception.

As for why it's been done this way, the bug this code was added in doesn't have any discussion about that, so we can only guess.

My guess is that for specifications Mozilla intended to implement it made sense to finalize ("freeze" in Mozilla's terms) the interfaces, so that they could be used from binary code without further modifications after new properties/methods of the interface got implemented. And it didn't seem to matter much one way or another.

If you're interested in hearing from the developers, you could ask in mozilla.dev.tech.dom or mozilla.dev.platform.

这篇关于Firefox上的document.domConfig有什么用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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