Skip to content

Commit

Permalink
fix sigil escaping in .textContent and .innerHTML (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
Conduitry committed Sep 22, 2017
1 parent abfb2ad commit 707405a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/generators/dom/visitors/Element/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 707405a

Please sign in to comment.