diff --git a/src/index.ts b/src/index.ts index ec18ed7..811e167 100755 --- a/src/index.ts +++ b/src/index.ts @@ -460,7 +460,7 @@ export class HTMLElement extends Node { return this._rawAttrs; 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] || ""; diff --git a/test/html.js b/test/html.js index 7f5dc02..f779771 100644 --- a/test/html.js +++ b/test/html.js @@ -264,12 +264,13 @@ describe('HTML Parser', function () { describe('#attributes', function () { it('should return attributes of the element', function () { - var root = parseHTML('

'); + var root = parseHTML('

'); root.firstChild.attributes.should.eql({ 'a': '12', 'data-id': '!$$&', 'yAz': '1', - 'disabled': '' + 'disabled': '', + 'class': '' }); }); });