From 48e1e723d40905c238cd2b6fb3ed62a4e7d89e31 Mon Sep 17 00:00:00 2001 From: taoqf Date: Thu, 14 Dec 2017 16:48:58 +0800 Subject: [PATCH] fixed: could not parse custom element --- src/index.ts | 2 +- test/html.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index c1bbc92..7287e97 100644 --- a/src/index.ts +++ b/src/index.ts @@ -550,7 +550,7 @@ export class Matcher { } } -const kMarkupPattern = /)-->|<(\/?)([a-z][a-z0-9]*)\s*([^>]*?)(\/?)>/ig; +const kMarkupPattern = /)-->|<(\/?)([a-z][a-z0-9]*-?[a-z0-9]*)\s*([^>]*?)(\/?)>/ig; const kAttributePattern = /(^|\s)(id|class)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig; const kSelfClosingElements = { meta: true, diff --git a/test/html.js b/test/html.js index c3635d2..b390035 100644 --- a/test/html.js +++ b/test/html.js @@ -263,4 +263,13 @@ describe('HTML Parser', function () { root.toString().should.eql(html) }); }); + + describe('Custom Element', function () { + it('parse "" tagName should be "my-widget"', function () { + + var root = parseHTML(''); + + root.firstChild.tagName.should.eql('my-widget'); + }); + }); });