diff --git a/index.js b/index.js index 2115542..0a40cf0 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,9 @@ function toHTML(node, parent) { if (isVNode(node)) { return openTag(node) + tagContent(node) + closeTag(node); } else if (isVText(node)) { - if (parent && parent.tagName.toLowerCase() === 'script') return String(node.text); + if (parent && (parent.tagName.toLowerCase() === 'script' + || parent.tagName.toLowerCase() === 'style')) + return String(node.text); return escape(String(node.text)); } diff --git a/test/test.js b/test/test.js index a44d41c..80a648a 100644 --- a/test/test.js +++ b/test/test.js @@ -77,6 +77,13 @@ describe('toHTML()', function () { assert.equal(toHTML(node), '
'); }); + it('should render style element correctly', function(){ + var node = new VNode('style',{},[ + new VText(".logo {background-image: url('/mylogo.png');}") + ]); + assert.equal(toHTML(node),""); + }); + it('should render data- attributes for dataset properties', function () { var node = new VNode('div', { dataset: {