Merge pull request #15 from Sharcoux/fix-namespace

Fix issue when parsing namespaces
This commit is contained in:
taoqf 2020-01-30 09:45:43 +08:00 committed by GitHub
commit 2ad3ea6fb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

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

View file

@ -171,6 +171,11 @@ describe('HTML Parser', function () {
});
it('should be able to parse namespaces', function () {
const namespacedXML = '<ns:identifier>content</ns:identifier>';
parseHTML(namespacedXML).toString().should.eql(namespacedXML);
});
it('should parse "<div><a><img/></a><p></p></div>.." very fast', function () {
for (var i = 0; i < 100; i++)