From c682e365f610b7a6faa83e853efa47477f7321b0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 30 Aug 2017 11:54:29 -0400 Subject: [PATCH] optimise case where we can use innerHTML --- src/generators/dom/visitors/RawMustacheTag.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/generators/dom/visitors/RawMustacheTag.ts b/src/generators/dom/visitors/RawMustacheTag.ts index ab0ff7991d..bbdbc5b26f 100644 --- a/src/generators/dom/visitors/RawMustacheTag.ts +++ b/src/generators/dom/visitors/RawMustacheTag.ts @@ -26,8 +26,10 @@ export default function visitRawMustacheTag( let detach: string; let insert: (content: string) => string; + let useInnerHTML = false; if (anchorBefore === 'null' && anchorAfter === 'null') { + useInnerHTML = true; detach = `${state.parentNode}.innerHTML = '';`; insert = content => `${state.parentNode}.innerHTML = ${content};`; } else if (anchorBefore === 'null') { @@ -48,7 +50,7 @@ export default function visitRawMustacheTag( node, name, content => deindent` - ${detach} + ${!useInnerHTML && detach} ${insert(content)} ` );