Fix issue when parsing namespaces

Signed-off-by: François BILLIOUD <f.billioud@gmail.com>
This commit is contained in:
François BILLIOUD 2020-01-29 16:18:18 +01:00
parent c145442179
commit 0fb0baa47f
2 changed files with 6 additions and 1 deletions

View file

@ -725,7 +725,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++)