diff --git a/src/nodes/comment.ts b/src/nodes/comment.ts index 820c3e9..16786bd 100644 --- a/src/nodes/comment.ts +++ b/src/nodes/comment.ts @@ -1,4 +1,3 @@ -import { decode } from 'he'; import Node from './node'; import NodeType from './type'; @@ -19,7 +18,7 @@ export default class CommentNode extends Node { * @return {string} text content */ get text() { - return decode(this.rawText); + return this.rawText; } toString() { diff --git a/src/nodes/text.ts b/src/nodes/text.ts index 96c081b..653a7eb 100644 --- a/src/nodes/text.ts +++ b/src/nodes/text.ts @@ -1,4 +1,3 @@ -import { decode } from 'he'; import NodeType from './type'; import Node from './node'; @@ -23,7 +22,7 @@ export default class TextNode extends Node { * @return {string} text content */ get text() { - return decode(this.rawText); + return this.rawText; } /** diff --git a/test/html.js b/test/html.js index fd24c4e..7929f83 100644 --- a/test/html.js +++ b/test/html.js @@ -526,6 +526,27 @@ describe('HTML Parser', function () { root.firstChild.getAttribute('alt').should.eql('«Sogno'); root.firstChild.rawAttributes.alt.should.eql('«Sogno'); }); + it('shoud not decode text', function () { + // https://github.com/taoqf/node-html-parser/issues/33 + const root = parseHTML(` + +
+<p> +This content should be enclosed within an escaped p tag<br /> +</p> +
+ +`) + root.toString().should.eql(` + +
+<p> +This content should be enclosed within an escaped p tag<br /> +</p> +
+ +`); + }); }); describe('#insertAdjacentHTML() should parse and insert childrens', function () {