Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* 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

This comment has been minimized.

Copy link
Owner Author

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

This comment has been minimized.

Copy link
Owner Author

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
You can’t perform that action at this time.