diff --git a/src/nodes/html.ts b/src/nodes/html.ts index 3dc6cc6..3ec4486 100644 --- a/src/nodes/html.ts +++ b/src/nodes/html.ts @@ -407,7 +407,7 @@ export default class HTMLElement extends Node { const attrs = this.rawAttributes; for (const key in attrs) { const val = attrs[key] || ''; - this._attrs[key] = decode(val.replace(/^['"]/, '').replace(/['"]$/, '')); + this._attrs[key] = decode(val); } return this._attrs; } @@ -477,12 +477,7 @@ export default class HTMLElement extends Node { if (val === undefined || val === null) { return name; } else { - return name + '=' + JSON.stringify(val); - // if (typeof val === 'string') { - // return name + '=' + JSON.stringify(encode(val)); //??? should we encode value here? - // } else { - // return name + '=' + JSON.stringify(val); - // } + return name + '=' + JSON.stringify(String(val)); } }).join(' '); } diff --git a/test/html.js b/test/html.js index efa1597..b3da8ad 100644 --- a/test/html.js +++ b/test/html.js @@ -355,7 +355,7 @@ describe('HTML Parser', function () { 'b': '13', 'c': '2' }); - root.firstChild.toString().should.eql('

'); + root.firstChild.toString().should.eql('

'); }); }); @@ -370,7 +370,7 @@ describe('HTML Parser', function () { 'c': '12', d: '&&<>foo' }); - root.firstChild.toString().should.eql('

'); + root.firstChild.toString().should.eql('

'); // root.firstChild.toString().should.eql('

'); }); });