taoqf / node-html-parser

A very fast HTML parser, generating a simplified DOM, with basic element query support.
MIT License
1.11k stars 107 forks source link

Added support for shorthand event handler syntax #212

Closed jjdbrrr closed 2 years ago

jjdbrrr commented 2 years ago

The HTML attribute regex does not capture attributes that start with an @ correctly. You might run into this when working with shorthand event handlers in micro-frameworks such as Alpine.js or petite-vue. This fixes that.

e.g. @click="doSmt()" yields attribute click with a value of doSmt(). With the current regex, rawAttrs does not contain the right value (it contains click without the @). This PR fixes that.

https://github.com/taoqf/node-html-parser/blob/05f474f751a93ea30590733380263d2f669a3987/src/nodes/html.ts#L690