Skip to content

Commit 20f65eb

Browse files
authored
Merge pull request ashi009#1 from raffecat/master
Allow custom element names with multiple dashes
2 parents a62f7d6 + 165ee2d commit 20f65eb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/index.ts

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

553-
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][a-z0-9]*-?[a-z0-9]*)\s*([^>]*?)(\/?)>/ig;
553+
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
554+
const kMarkupPattern = /<!--[^]*?(?=-->)-->|<(\/?)([a-z][-.0-9_a-z]*)\s*([^>]*?)(\/?)>/ig;
554555
const kAttributePattern = /(^|\s)(id|class)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig;
555556
const kSelfClosingElements = {
556557
meta: true,

test/html.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,13 @@ describe('HTML Parser', function () {
272272
root.firstChild.tagName.should.eql('my-widget');
273273
});
274274
});
275+
276+
describe('Custom Element multiple dash', function () {
277+
it('parse "<my-new-widget></my-new-widget>" tagName should be "my-new-widget"', function () {
278+
279+
var root = parseHTML('<my-new-widget></my-new-widget>');
280+
281+
root.firstChild.tagName.should.eql('my-new-widget');
282+
});
283+
});
275284
});

0 commit comments

Comments
 (0)