diff --git a/lib/htmlparser-to-vdom.js b/lib/htmlparser-to-vdom.js index 9993453..514a23c 100644 --- a/lib/htmlparser-to-vdom.js +++ b/lib/htmlparser-to-vdom.js @@ -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. diff --git a/test/html-to-vdom/lib/html-to-vdom/index.js b/test/html-to-vdom/lib/html-to-vdom/index.js index 2a09fba..d73aaa5 100644 --- a/test/html-to-vdom/lib/html-to-vdom/index.js +++ b/test/html-to-vdom/lib/html-to-vdom/index.js @@ -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 = '
'; + 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 = """;'); + }) }); describe('when converting HTML containing a style tag', function () {