Skip to content

Commit 36d3c28

Browse files
authored
Merge pull request #212 from janjoost-denbrinker/main
Added support for shorthand event handler syntax
2 parents 6937982 + 7a78155 commit 36d3c28

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/nodes/html.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ export default class HTMLElement extends Node {
687687
}
688688
const attrs = {} as RawAttributes;
689689
if (this.rawAttrs) {
690-
const re = /([a-zA-Z()[\]#][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
690+
const re = /([a-zA-Z()[\]#@][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
691691
let match: RegExpExecArray;
692692
while ((match = re.exec(this.rawAttrs))) {
693693
const key = match[1];

test/tests/html.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,12 @@ describe('HTML Parser', function () {
214214

215215
describe('#rawAttributes', function () {
216216
it('should return escaped attributes of the element', function () {
217-
const root = parseHTML('<p a=12 data-id="!$$&amp;" yAz=\'1\'></p>');
217+
const root = parseHTML('<p a=12 data-id="!$$&amp;" yAz=\'1\' @click="doSmt()"></p>');
218218
root.firstChild.rawAttributes.should.eql({
219219
'a': '12',
220220
'data-id': '!$$&amp;',
221-
'yAz': '1'
221+
'yAz': '1',
222+
'@click': 'doSmt()'
222223
});
223224
});
224225
});

0 commit comments

Comments
 (0)