aurelia / template-lint

Sanity check of Aurelia-flavor template HTML
Apache License 2.0
56 stars 17 forks source link

'startOffset' is undefined when svg namespace used #117

Closed bondib closed 7 years ago

bondib commented 7 years ago

TypeError: Cannot read property 'startOffset' of undefined

TypeError: Cannot read property 'startOffset' of undefined at ...//node_modules/template-lint/dist/ast.js:30:49 at Array.map (native) at Parser. (...//node_modules/template-lint/dist/ast.js:26:32) at emitMany (events.js:126:20) at Parser.emit (events.js:195:7) at Parser.SAXParser._handleToken (...//node_modules/parse5/lib/sax/index.js:171:14) at Parser.SAXParser._runParsingLoop (...//node_modules/parse5/lib/sax/index.js:149:18) at Parser.SAXParser._transform (...//node_modules/parse5/lib/sax/index.js:76:14) at Parser.Transform._read (_stream_transform.js:167:10) at Parser.Transform._write (_stream_transform.js:155:12) at doWrite (_stream_writable.js:300:12) at writeOrBuffer (_stream_writable.js:286:5) at Parser.Writable.write (_stream_writable.js:214:11) at Readable.ondata (_stream_readable.js:536:20) at emitOne (events.js:90:13) at Readable.emit (events.js:182:7) at Readable.read (_stream_readable.js:368:10) at flow (_streamreadable.js:751:26) at emitReadable (_stream_readable.js:420:3) at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9)

MeirionHughes commented 7 years ago

Can you rimraf your node_modules and make sure you're on 0.9.8. If it still happens, could you post the html that causes it to die?

bondib commented 7 years ago

Hi. So yes - i'm using 0.9.8.

I debugged it and found the issue (I think). It's with the following html:

${userContext.caps}

It fails on xmlns as attrLoc is undefined with this attribute - as a previous check is strangely incorrect (x.prefix !== undefined) which makes the attribute name become ":xmlns" instead of just "xmlns"...

bondib commented 7 years ago

The html:

`

                                <text x="50%" y="50%" text-anchor="middle" stroke="#51c5cf" stroke-width="2px" dy=".3em" letter-spacing="2">${userContext.caps}</text>
                            </svg>`
MeirionHughes commented 7 years ago

ahh yeh, its because parse5 changed how it deals with attribute names and namespaces. I'll sort this when I get home.

bondib commented 7 years ago

Great, thanks!

I have another one for you... Will open a different issue... :-)

MeirionHughes commented 7 years ago

published as aurelia-template-lint 0.9.9. Also require template-lint 0.8.9