aredridel / html5

Event-driven HTML5 Parser in Javascript
http://dinhe.net/~aredridel/projects/js/html5/
MIT License
590 stars 168 forks source link

activeFormattingElements not reset in treebuilder between parses #60

Closed gwicke closed 11 years ago

gwicke commented 12 years ago
var html5 = require('html5').HTML5;
var p = new html5.Parser();

p.parse('<p><u>foo</p>');
p.parse('<p>bar</p>');
console.log( p.document.innerHTML );

-> <html><head></head><body><p><u>bar</u></p></body></html>

Not 100% sure if this is correct in all cases, but moving the initialization of open_elements and activeFormattingElements to TreeBuilder.prototype.reset and calling it from the constructor fixes this issue for me. Will send a pull request with this change.