From bf58b494180ffd6ed604fcea2069f69dd99b94dd Mon Sep 17 00:00:00 2001 From: Sergio Garcia Murillo Date: Mon, 23 Feb 2015 16:41:24 +0100 Subject: [PATCH] parse string content as raw string --- packages/html-tools/parse.js | 2 ++ packages/html-tools/parse_tests.js | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/html-tools/parse.js b/packages/html-tools/parse.js index cf4602cb34..4a830dc54c 100644 --- a/packages/html-tools/parse.js +++ b/packages/html-tools/parse.js @@ -170,6 +170,8 @@ getContent = HTMLTools.Parse.getContent = function (scanner, shouldStopFunc) { attrs.value = textareaValue; } } + } else if (token.n === 'script') { + content = getRawText(scanner, token.n, shouldStopFunc); } else { content = getContent(scanner, shouldStopFunc); } diff --git a/packages/html-tools/parse_tests.js b/packages/html-tools/parse_tests.js index 6bac32fd5b..987f123353 100644 --- a/packages/html-tools/parse_tests.js +++ b/packages/html-tools/parse_tests.js @@ -13,6 +13,7 @@ var A = HTML.A; var DIV = HTML.DIV; var P = HTML.P; var TEXTAREA = HTML.TEXTAREA; +var SCRIPT = HTML.SCRIPT; Tinytest.add("html-tools - parser getContent", function (test) { @@ -149,6 +150,8 @@ Tinytest.add("html-tools - parser getContent", function (test) { succeed('
', BR({x:'\n\n'})); succeed('
', BR({x:'y'})); fatal('
'); + succeed('',SCRIPT('var x="
";')); + succeed('',SCRIPT('var x=1 && 0;')); }); Tinytest.add("html-tools - parseFragment", function (test) { @@ -365,5 +368,4 @@ Tinytest.add("html-tools - getTemplateTag", function (test) { succeed('', TEXTAREA(Attrs({x:"1"}, TemplateTag({stuff: 'a'}), TemplateTag({stuff: 'b'})))); - });