mirror of
https://github.com/danbulant/node-html-parser
synced 2026-05-19 04:18:52 +00:00
🐛 fix #33
This commit is contained in:
parent
667f09d923
commit
b05eb5c127
3 changed files with 23 additions and 4 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
21
test/html.js
21
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(`<html>
|
||||
<body>
|
||||
<div id='source'>
|
||||
<p>
|
||||
This content should be enclosed within an escaped p tag<br />
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`)
|
||||
root.toString().should.eql(`<html>
|
||||
<body>
|
||||
<div id='source'>
|
||||
<p>
|
||||
This content should be enclosed within an escaped p tag<br />
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#insertAdjacentHTML() should parse and insert childrens', function () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue