0
延伸
我使用 “HTML5” 的Node.js库的基础上, “jsdom” 库(https://github.com/aredridel/html5)样机的NodeList
我的代码是:
var HTML5 = require('/usr/lib/node_modules/html5/lib/html5'),
Script = process.binding('evals').Script,
util = require('util'),
fs = require('fs');
var p = new HTML5.Parser();
p.parse_fragment(fs.readFileSync('test.xml'));
现在我有p
对象,它具有p.tree.body_pointer._childNodes
NodeList
(尝试使用p.tree.body_pointer._childNodes.constructor来查看)。
我想通过我的方法扩展它,以便能够拨打p.tree.body_pointer._childNodes.foo()
。
我试过NodeList.prototype.foo = function(){return“OK”}但我得到NodeList没有定义错误消息。
我猜NodeList是在我找不到的东西里面声明的。查看源代码,我发现它在core
或dom
下,但是两者都不能从我的代码中获得。
另外我扫描了HTML5对象 - 但没有成功。
任何想法?
谢谢! :) – Alexander 2013-03-10 08:16:06