optimise case where we can use innerHTML

pull/803/head
Rich Harris 7 years ago
parent d1a6f9c11e
commit c682e365f6

@ -26,8 +26,10 @@ export default function visitRawMustacheTag(
let detach: string; let detach: string;
let insert: (content: string) => string; let insert: (content: string) => string;
let useInnerHTML = false;
if (anchorBefore === 'null' && anchorAfter === 'null') { if (anchorBefore === 'null' && anchorAfter === 'null') {
useInnerHTML = true;
detach = `${state.parentNode}.innerHTML = '';`; detach = `${state.parentNode}.innerHTML = '';`;
insert = content => `${state.parentNode}.innerHTML = ${content};`; insert = content => `${state.parentNode}.innerHTML = ${content};`;
} else if (anchorBefore === 'null') { } else if (anchorBefore === 'null') {
@ -48,7 +50,7 @@ export default function visitRawMustacheTag(
node, node,
name, name,
content => deindent` content => deindent`
${detach} ${!useInnerHTML && detach}
${insert(content)} ${insert(content)}
` `
); );

Loading…
Cancel
Save