Skip to content

Commit 48e1e72

Browse files
committed
fixed: could not parse custom element
1 parent 89f0c21 commit 48e1e72

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ export class Matcher {
550550
}
551551
}
552552

553-
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][a-z0-9]*)\s*([^>]*?)(\/?)>/ig;
553+
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][a-z0-9]*-?[a-z0-9]*)\s*([^>]*?)(\/?)>/ig;
554554
const kAttributePattern = /(^|\s)(id|class)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig;
555555
const kSelfClosingElements = {
556556
meta: true,

test/html.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,4 +263,13 @@ describe('HTML Parser', function () {
263263
root.toString().should.eql(html)
264264
});
265265
});
266+
267+
describe('Custom Element', function () {
268+
it('parse "<my-widget></my-widget>" tagName should be "my-widget"', function () {
269+
270+
var root = parseHTML('<my-widget></my-widget>');
271+
272+
root.firstChild.tagName.should.eql('my-widget');
273+
});
274+
});
266275
});

0 commit comments

Comments
 (0)