diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index eed7c6f4eee..8e8e0d6706e 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -1052,7 +1052,10 @@ export default class ElementWrapper extends Wrapper { block.chunks.update.push(updater); } else if ((dependencies && dependencies.size > 0) || this.class_dependencies.length) { const all_dependencies = this.class_dependencies.concat(...dependencies); - const condition = block.renderer.dirty(all_dependencies); + let condition = block.renderer.dirty(all_dependencies); + if (block.has_outros) { + condition = x`!#current || ${condition}`; + } // If all of the dependencies are non-dynamic (don't get updated) then there is no reason // to add an updater for this. diff --git a/test/runtime/samples/class-shortcut-with-transition/_config.js b/test/runtime/samples/class-shortcut-with-transition/_config.js new file mode 100644 index 00000000000..80df51bd4a3 --- /dev/null +++ b/test/runtime/samples/class-shortcut-with-transition/_config.js @@ -0,0 +1,30 @@ +export default { + props: { + open: false, + border: true + }, + html: '

foo

', + + test({ assert, component, target, raf }) { + component.open = true; + raf.tick(100); + assert.htmlEqual( + target.innerHTML, + '

foo

bar

' + ); + + component.open = false; + raf.tick(150); + assert.htmlEqual( + target.innerHTML, + '

foo

bar

' + ); + + component.open = true; + raf.tick(250); + assert.htmlEqual( + target.innerHTML, + '

foo

bar

' + ); + } +}; diff --git a/test/runtime/samples/class-shortcut-with-transition/main.svelte b/test/runtime/samples/class-shortcut-with-transition/main.svelte new file mode 100644 index 00000000000..3291ec4a107 --- /dev/null +++ b/test/runtime/samples/class-shortcut-with-transition/main.svelte @@ -0,0 +1,17 @@ + + +

foo

+{#if open} +

bar

+{/if} + +