Merge pull request #1 from raffecat/master

Allow custom element names with multiple dashes
This commit is contained in:
taoqf 2018-08-27 12:53:02 +08:00 committed by GitHub
commit 20f65eb5de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

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

View file

@ -272,4 +272,13 @@ describe('HTML Parser', function () {
root.firstChild.tagName.should.eql('my-widget');
});
});
describe('Custom Element multiple dash', function () {
it('parse "<my-new-widget></my-new-widget>" tagName should be "my-new-widget"', function () {
var root = parseHTML('<my-new-widget></my-new-widget>');
root.firstChild.tagName.should.eql('my-new-widget');
});
});
});