Skip to content

Commit

Permalink
fix issue #42
Browse files Browse the repository at this point in the history
  • Loading branch information
taoqf committed Apr 15, 2021
1 parent 558d762 commit 2fe99f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/nodes/html.ts
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions test/42.js
@@ -0,0 +1,9 @@
const { parse } = require('../dist');

describe('issue 42', function () {
it('svg attribute', function () {
const root = parse('<p a=12 data-id="!$$&amp;" yAz=\'1\' xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></p>');
const p = root.querySelector('p');
p.getAttribute('xmlns:xlink').should.eql('http://www.w3.org/1999/xlink');
});
});

0 comments on commit 2fe99f1

Please sign in to comment.