Skip to content

Instantly share code, notes, and snippets.

@Valid
Created October 21, 2010 01:26
Show Gist options
  • Save Valid/637738 to your computer and use it in GitHub Desktop.
Save Valid/637738 to your computer and use it in GitHub Desktop.
ubuntu@domU-12-31-38-02-50-19:/usr/local/lib/node/.npm/html5/active/package$ ls
COPYING doc lib n package.json tc.html temp.tar.gz test.js t.html tools
deps DOCUMENTATION.md Makefile n2 README.md tc.js testdata tests t.js t.sh
ubuntu@domU-12-31-38-02-50-19:/usr/local/lib/node/.npm/html5/active/package$ cat ~/webroot/test.js
var HTML5 = require('html5'),
Script = process.binding('evals').Script,
sys = require('sys'),
fs = require('fs'),
jsdom = require('jsdom'),
window = jsdom.createWindow(null, null, {parser: HTML5});
var parser = new HTML5.Parser({document: window.document});
var inputfile = fs.readFileSync('doc/jquery-example.html');
parser.parse(inputfile);
jsdom.jQueryify(window, 'deps/jquery/dist/jquery.js', function(window, jquery) {
Script.runInNewContext('jQuery("p").append("<b>Hi!</b>")', window);
sys.puts(window.document.innerHTML);
});
ubuntu@domU-12-31-38-02-50-19:/usr/local/lib/node/.npm/html5/active/package$ node ~/webroot/test.js
ubuntu@domU-12-31-38-02-50-19:/usr/local/lib/node/.npm/html5/active/package$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment