有没有办法从JavaScript Node接口继承? [英] Is there a way to inherit from the javascript Node interface?

查看:110
本文介绍了有没有办法从JavaScript Node接口继承?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一些继承自DOM Node接口的JavaScript类...听起来非常像如何从dom-element-class继承,但是我不想在我的[X | XHT | HT] ML文档中使用它的实例。我的目标是建立一个绝对的独立的DOM树,所以我想使用 Node接口由现代浏览器提供,而不是创建我自己的DOM实现。节点不应该有任何HTML属性,如类名,样式或(客户端)偏移量 - 只是一个简单的节点。该类不需要扩展,Node方法就足够了。

I want to write some javascript classes which inherit from the DOM Node interface... Sounds very much like how-to-inherit-from-the-dom-element-class, but I do not want to use its instances it in my [X|XHT|HT]ML document. My aim is to build a absolutely stand-alone DOM tree, so I would like to use the Node interface provided by modern browsers instead of creating my own DOM implementation. The nodes should not have any HTML attributes like classname, styles or (client)offsets - just a plain Node. The class doesn't need to be extensible, the Node methods would be enough.

如果有可能创建一个DocumentFragment或一个新文档,我也会很高兴哪个

a)不是(X)HTML文档,而是XML文档,

b)与当前文档没有关联(如 document.implementation

I would also be happy if there was a possibility to create a DocumentFragment or a new Document which
a) is not a (X)HTML document but a XML document and
b) is not associated with the current document (as in document.implementation)

脚本应该在最新版本的Opera和Firefox。其他浏览器是一个很好的,不是必须的;我不关心任何旧版本。

The script should work in the latest versions of Opera and Firefox. Other browsers are a nice-to-have, not a must; and I don't care about any old versions.

推荐答案

似乎这是最接近我的要求: / p>

It seems to be that this is the closest to my requirements:

new DOMParser().parseFromString("<root />", "text/xml");

但仍然没有办法从Node接口继承。

But still no way to inherit from the Node interface.

这篇关于有没有办法从JavaScript Node接口继承?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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