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.
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.