Skip to content

Commit

Permalink
Merge 98bff74 into 42c1229
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinHu-1024 committed Nov 2, 2018
2 parents 42c1229 + 98bff74 commit 9f11fd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/htmlparser-to-vdom.js
Expand Up @@ -7,6 +7,9 @@ module.exports = function createConverter (VNode, VText) {
if (node.type === 'tag' || node.type === 'script' || node.type === 'style') {
return converter.convertTag(node, getVNodeKey);
} else if (node.type === 'text') {
if (node.parent && node.parent.type === 'script') {
return new VText(node.data);
}
return new VText(decode(node.data));
} else {
// converting an unsupported node, return an empty text node instead.
Expand Down
9 changes: 9 additions & 0 deletions test/html-to-vdom/lib/html-to-vdom/index.js
Expand Up @@ -129,6 +129,15 @@ describe('html-to-vdom', function () {
script.children.length.should.eql(1);
script.children[0].text.should.eql('alert("bar!");');
});
it('converts script tag which contains html entity string', function() {
var html = '<div><script>var s = "&quot;";</script></div>';
var converted = convertHTML(html);
var script = converted.children[0];
should.exist(script);
script.tagName.should.eql('script');
script.children.length.should.eql(1);
script.children[0].text.should.eql('var s = "&quot;";');
})
});

describe('when converting HTML containing a style tag', function () {
Expand Down

0 comments on commit 9f11fd9

Please sign in to comment.