Skip to content

Commit

Permalink
[fix] style: directive should prevent innerHTML optimization (#7390)
Browse files Browse the repository at this point in the history
Fixes #7386
  • Loading branch information
tivac committed Mar 30, 2022
1 parent 0eee98a commit 9f4602a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/compiler/compile/render_dom/wrappers/Element/index.ts
Expand Up @@ -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
) {
Expand Down
4 changes: 3 additions & 1 deletion test/runtime/samples/inline-style-directive/_config.js
@@ -1,6 +1,8 @@
export default {
html: `
<p style="color: red;"></p>
<div>
<p style="color: red;"></p>
</div>
`,

test({ assert, target, window }) {
Expand Down
4 changes: 3 additions & 1 deletion test/runtime/samples/inline-style-directive/main.svelte
Expand Up @@ -2,4 +2,6 @@
export let myColor = "red";
</script>

<p style:color={myColor} />
<div>
<p style:color={myColor} />
</div>
4 changes: 2 additions & 2 deletions test/runtime/samples/inline-style/_config.js
Expand Up @@ -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');
}
};

0 comments on commit 9f4602a

Please sign in to comment.