From 9f4602ac6f908dbc1d04ffea3c47ac5760b3c3e0 Mon Sep 17 00:00:00 2001 From: Pat Cavit Date: Wed, 30 Mar 2022 07:49:25 -0700 Subject: [PATCH] [fix] style: directive should prevent innerHTML optimization (#7390) Fixes #7386 --- src/compiler/compile/render_dom/wrappers/Element/index.ts | 1 + test/runtime/samples/inline-style-directive/_config.js | 4 +++- test/runtime/samples/inline-style-directive/main.svelte | 4 +++- test/runtime/samples/inline-style/_config.js | 4 ++-- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index eb57233ed0..989e7cb82b 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -219,6 +219,7 @@ export default class ElementWrapper extends Wrapper { node.classes.length > 0 || node.intro || node.outro || node.handlers.length > 0 || + node.styles.length > 0 || this.node.name === 'option' || renderer.options.dev ) { diff --git a/test/runtime/samples/inline-style-directive/_config.js b/test/runtime/samples/inline-style-directive/_config.js index ec32e157e5..f5732ae0af 100644 --- a/test/runtime/samples/inline-style-directive/_config.js +++ b/test/runtime/samples/inline-style-directive/_config.js @@ -1,6 +1,8 @@ export default { html: ` -

+
+

+
`, test({ assert, target, window }) { diff --git a/test/runtime/samples/inline-style-directive/main.svelte b/test/runtime/samples/inline-style-directive/main.svelte index 1d60aefa6f..ff8acfce68 100644 --- a/test/runtime/samples/inline-style-directive/main.svelte +++ b/test/runtime/samples/inline-style-directive/main.svelte @@ -2,4 +2,6 @@ export let myColor = "red"; -

+

+

+

diff --git a/test/runtime/samples/inline-style/_config.js b/test/runtime/samples/inline-style/_config.js index 3e984d4c69..192659346c 100644 --- a/test/runtime/samples/inline-style/_config.js +++ b/test/runtime/samples/inline-style/_config.js @@ -4,9 +4,9 @@ export default { `, test({ assert, component, target, window }) { - const p = target.querySelector('div'); + const div = target.querySelector('div'); - const styles = window.getComputedStyle(p); + const styles = window.getComputedStyle(div); assert.equal(styles.color, 'red'); } };