Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hober/478925 to your computer and use it in GitHub Desktop.
Save hober/478925 to your computer and use it in GitHub Desktop.
/* Using aredridel/html5 and tmpvar/jsdom */
var sys = require('sys');
var HTML5 = require('html5');
var p = new HTML5.Parser("<p>hello, world");
p.parse();
var doc = p.document;
var head = doc.getElementsByTagName('head').item(0);
var metaCharset = doc.createElement('meta');
head.appendChild(metaCharset);
metaCharset.setAttribute('charset', 'utf-8');
sys.puts(HTML5.serialize(doc));
@hober
Copy link
Author

hober commented Jul 16, 2010

This is what gets printed when I run the above:

<HTML><HEAD><META></META></HEAD><BODY><P>hello, world</P></BODY></HTML>

Notice the incorrect meta element.

@hober
Copy link
Author

hober commented Jul 16, 2010

metaCharset._attributes.length is 0, which leads me to believe the problem is in jsdom.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment