aredridel / html5

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

fix addAttributesToElement in SAXTreeBuilder #106

Closed coderaiser closed 10 years ago

coderaiser commented 10 years ago

Element.attributes could be undefined. And it is undfined when I'm editing html-document in ace with html-worker which is use html5.

There is error log:

Worker TypeError: Cannot read property 'length' of undefined
    at getAttribute (http://io.cloudcmd.io/lib/client/edit/worker-html.js:7638:37)
    at SAXTreeBuilder.addAttributesToElement (http://io.cloudcmd.io/lib/client/edit/worker-html.js:7649:12)
    at Object.TreeBuilder.modes.base.startTagHtml (http://io.cloudcmd.io/lib/client/edit/worker-html.js:4361:9)
    at Object.TreeBuilder.modes.base.processStartTag (http://io.cloudcmd.io/lib/client/edit/worker-html.js:4340:40)
    at SAXTreeBuilder.TreeBuilder.processToken (http://io.cloudcmd.io/lib/client/edit/worker-html.js:6791:17)
    at Tokenizer._emitToken (http://io.cloudcmd.io/lib/client/edit/worker-html.js:2727:21)
    at Tokenizer._emitCurrentToken (http://io.cloudcmd.io/lib/client/edit/worker-html.js:2735:7)
    at Tokenizer.after_attribute_value_state (http://io.cloudcmd.io/lib/client/edit/worker-html.js:3608:14)
    at Tokenizer.tokenize (http://io.cloudcmd.io/lib/client/edit/worker-html.js:2764:21)
    at SAXParser.parse (http://io.cloudcmd.io/lib/client/edit/worker-html.js:7516:18) 

You could check this if try to edit first line of index.html in editor of my project.

I'm using Chrome Version 33.0.1750.154 m

danyaPostfactum commented 10 years ago

Thanks, this is already fixed https://github.com/aredridel/html5/commit/1a85e58683a4c5327803e7fc0a0eba4bf99edf1c

Ace worker is not up to date.