From f8463f833c87e4eb3b90f80fa79bde4e8d50b381 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 8 Jul 2018 01:47:38 -0400 Subject: [PATCH] fix determing whether an attribute should prevent innerHTML optimization Fixes #1581 --- src/compile/nodes/Element.ts | 8 +++++++- .../samples/attribute-dynamic-no-dependencies/_config.js | 5 +++++ .../samples/attribute-dynamic-no-dependencies/main.html | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/runtime/samples/attribute-dynamic-no-dependencies/_config.js create mode 100644 test/runtime/samples/attribute-dynamic-no-dependencies/main.html diff --git a/src/compile/nodes/Element.ts b/src/compile/nodes/Element.ts index a2a6f8d5b4dd..403b9cce8bee 100644 --- a/src/compile/nodes/Element.ts +++ b/src/compile/nodes/Element.ts @@ -152,8 +152,14 @@ export default class Element extends Node { ); this.attributes.forEach(attr => { - if (attr.dependencies.size) { + if ( + attr.chunks && + attr.chunks.length && + (attr.chunks.length > 1 || attr.chunks[0].type !== 'Text') + ) { this.parent.cannotUseInnerHTML(); + } + if (attr.dependencies.size) { block.addDependencies(attr.dependencies); // special case —