From 707405af7a7532f683a2dfc766aaf12ed1ca77df Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 22 Sep 2017 10:31:59 -0400 Subject: [PATCH 1/3] fix sigil escaping in .textContent and .innerHTML (#868) --- src/generators/dom/visitors/Element/Element.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/generators/dom/visitors/Element/Element.ts b/src/generators/dom/visitors/Element/Element.ts index 8b42d40a1891..fe874790d04c 100644 --- a/src/generators/dom/visitors/Element/Element.ts +++ b/src/generators/dom/visitors/Element/Element.ts @@ -16,6 +16,7 @@ import Block from '../../Block'; import { Node } from '../../../../interfaces'; import { State } from '../../interfaces'; import reservedNames from '../../../../utils/reservedNames'; +import { stringify } from '../../../../utils/stringify'; const meta = { ':Window': visitWindow, @@ -205,11 +206,11 @@ export default function visitElement( if (!childState.namespace && node.canUseInnerHTML && node.children.length > 0) { if (node.children.length === 1 && node.children[0].type === 'Text') { block.builders.create.addLine( - `${name}.textContent = ${JSON.stringify(node.children[0].data)};` + `${name}.textContent = ${stringify(node.children[0].data)};` ); } else { block.builders.create.addLine( - `${name}.innerHTML = ${JSON.stringify(node.children.map(toHTML).join(''))};` + `${name}.innerHTML = ${stringify(node.children.map(toHTML).join(''))};` ); } } else { From 7b25b1202f5b18b9480363d27fbb61ff9a77a62b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 22 Sep 2017 10:35:45 -0400 Subject: [PATCH 2/3] expand unit test --- test/runtime/samples/escaped-text/_config.js | 15 ++++++++++++++- test/runtime/samples/escaped-text/main.html | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/runtime/samples/escaped-text/_config.js b/test/runtime/samples/escaped-text/_config.js index 43644dde8241..85235fe56d39 100644 --- a/test/runtime/samples/escaped-text/_config.js +++ b/test/runtime/samples/escaped-text/_config.js @@ -3,5 +3,18 @@ export default { @@x %1 %%2 + +
+ @@x + %1 + %%2 +
+ +
+ @@x + %1 + %%2 + inner +
` -}; \ No newline at end of file +}; diff --git a/test/runtime/samples/escaped-text/main.html b/test/runtime/samples/escaped-text/main.html index 603b331ca666..0b3109d693d8 100644 --- a/test/runtime/samples/escaped-text/main.html +++ b/test/runtime/samples/escaped-text/main.html @@ -1,3 +1,16 @@ @@x %1 -%%2 \ No newline at end of file +%%2 + +
+ @@x + %1 + %%2 +
+ +
+ @@x + %1 + %%2 + inner +
From 9c7c5b9636b60841c433cb862b60da7a4cc4f55b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 22 Sep 2017 11:24:05 -0400 Subject: [PATCH 3/3] more testing --- test/runtime/samples/escaped-text/_config.js | 9 +++++++++ test/runtime/samples/escaped-text/main.html | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/test/runtime/samples/escaped-text/_config.js b/test/runtime/samples/escaped-text/_config.js index 85235fe56d39..206a1afb51d0 100644 --- a/test/runtime/samples/escaped-text/_config.js +++ b/test/runtime/samples/escaped-text/_config.js @@ -1,17 +1,26 @@ export default { html: ` + @x @@x + #foo + ##foo %1 %%2
+ @x @@x + #foo + ##foo %1 %%2
+ @x @@x + #foo + ##foo %1 %%2 inner diff --git a/test/runtime/samples/escaped-text/main.html b/test/runtime/samples/escaped-text/main.html index 0b3109d693d8..cbcb7fdbb0e3 100644 --- a/test/runtime/samples/escaped-text/main.html +++ b/test/runtime/samples/escaped-text/main.html @@ -1,15 +1,24 @@ +@x @@x +#foo +##foo %1 %%2
+ @x @@x + #foo + ##foo %1 %%2
+ @x @@x + #foo + ##foo %1 %%2 inner