Skip to content

Commit

Permalink
fix issue #145
Browse files Browse the repository at this point in the history
  • Loading branch information
taoqf committed Aug 28, 2021
1 parent 418434b commit f6d406c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/nodes/html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ export default class HTMLElement extends Node {
}
const attrs = {} as RawAttributes;
if (this.rawAttrs) {
const re = /\b([a-z][a-z0-9-_:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/ig;
const re = /([a-z()#][a-z0-9-_:()#]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/ig;
let match: RegExpExecArray;
while ((match = re.exec(this.rawAttrs))) {
attrs[match[1]] = match[2] || match[3] || match[4] || null;
Expand Down
2 changes: 1 addition & 1 deletion test/135.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { parse, TextNode, HTMLElement } = require('../dist');
const { parse } = require('../dist');

describe('pr 135', function () {
it('shoud not decode text', function () {
Expand Down
13 changes: 13 additions & 0 deletions test/145.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { parse } = require('../dist');

describe('issue 145', function () {
it('shoud parse attributes right', function () {
const html = `<input matInput (keyup)="applyFilter($event)" placeholder="Ex. IMEI" #input>`;
const root = parse(html);
const div = root.firstChild;
div.getAttribute('#input').should.eql('');
div.getAttribute('(keyup)').should.eql('applyFilter($event)');
div.getAttribute('placeholder').should.eql('Ex. IMEI');
root.innerHTML.should.eql(html);
});
});

0 comments on commit f6d406c

Please sign in to comment.