aredridel / html5

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

p.endSelectTag does not pass a context to this.parser.reset_insertion_mode() [w/ fix] #12

Closed boblail closed 13 years ago

boblail commented 13 years ago

I'm not quite certain of the events that lead html5 to the following state, but running capybara's expectations on zombie.js I get this stack trace:

 TypeError: Cannot read property 'tagName' of undefined
   at EventEmitter.reset_insertion_mode (/usr/local/lib/node/.npm/html5/9999.0.0-LINK-3d23ff1b/package/lib/html5/parser.js:190:24)
   at Object.endTagSelect (/usr/local/lib/node/.npm/html5/9999.0.0-LINK-3d23ff1b/package/lib/html5/parser/in_select_phase.js:81:15)

Poking around, I see that Parser.prototype.reset_insertion_mode expects a context parameter but p.endTagSelect does not supply one. I looked for similar patterns in your code and saw that p.prototype.endTagTable in end_table_phase.js is very similar to p.endTagSelect and it supplies this.tree.open_elements.last() to reset_insertion_mode.

I made that change and zombie plowed forward.

Here's the commit: boblail/html5@18c09b9e78e3c384babdbc66afae41babaec57af.

I'll send a pull request.

aredridel commented 13 years ago

Thanks for the pull request!