From 2fe99f14cc661108c0944651f3266e88a0c4a36a Mon Sep 17 00:00:00 2001 From: taoqf Date: Thu, 15 Apr 2021 09:55:14 +0800 Subject: [PATCH] fix issue #42 --- src/nodes/html.ts | 2 +- test/42.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/42.js diff --git a/src/nodes/html.ts b/src/nodes/html.ts index 6dbe9d3..b6738b5 100644 --- a/src/nodes/html.ts +++ b/src/nodes/html.ts @@ -584,7 +584,7 @@ export default class HTMLElement extends Node { } const attrs = {} as RawAttributes; if (this.rawAttrs) { - const re = /\b([a-z][a-z0-9-_]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/ig; + const re = /\b([a-z][a-z0-9-_:]*)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|(\S+)))?/ig; let match: RegExpExecArray; while ((match = re.exec(this.rawAttrs))) { attrs[match[1]] = match[2] || match[3] || match[4] || null; diff --git a/test/42.js b/test/42.js new file mode 100644 index 0000000..43a07cd --- /dev/null +++ b/test/42.js @@ -0,0 +1,9 @@ +const { parse } = require('../dist'); + +describe('issue 42', function () { + it('svg attribute', function () { + const root = parse('

'); + const p = root.querySelector('p'); + p.getAttribute('xmlns:xlink').should.eql('http://www.w3.org/1999/xlink'); + }); +});