Event-driven HTML5 Parser in Javascript