Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save hober/478925 to your computer and use it in GitHub Desktop.

Select an option

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

hober commented Jul 16, 2010

Copy link
Copy Markdown
Author

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

hober commented Jul 16, 2010

Copy link
Copy Markdown
Author

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