diff --git a/src/compiler/compile/render_dom/wrappers/Element/index.ts b/src/compiler/compile/render_dom/wrappers/Element/index.ts index e9d9fc8f4b..504923b247 100644 --- a/src/compiler/compile/render_dom/wrappers/Element/index.ts +++ b/src/compiler/compile/render_dom/wrappers/Element/index.ts @@ -294,14 +294,13 @@ export default class ElementWrapper extends Wrapper { const if_statement = x`${not_equal}(${previous_tag}, ${previous_tag} = ${snippet})`; block.chunks.update.unshift(b` + ${this.var}.p(#ctx, #dirty); if (${if_statement}) { ${this.var}.d(1); ${this.var} = ${this.child_dynamic_element_block.name}(#ctx); ${this.var}.c(); @transition_in(${this.var}); this.m(${this.get_update_mount_node(anchor)}, ${anchor}); - } else { - ${this.var}.p(#ctx, #dirty); } `); diff --git a/test/runtime/samples/dynamic-element-action-update/_config.js b/test/runtime/samples/dynamic-element-action-update/_config.js new file mode 100644 index 0000000000..c2c6c16451 --- /dev/null +++ b/test/runtime/samples/dynamic-element-action-update/_config.js @@ -0,0 +1,21 @@ +export default { + html: ` +

tag is h1.

+ `, + + async test({ assert, component, target }) { + + assert.equal(component.tag, 'h1'); + assert.equal(component.updateText, ''); + assert.equal(component.destroyText, ''); + + component.tag = 'h2'; + + assert.equal(component.tag, 'h2'); + assert.equal(component.updateText, 'update: h2'); + assert.equal(component.destroyText, 'destroy'); + assert.htmlEqual(target.innerHTML, ` +

tag is h2.

+ `); + } +}; diff --git a/test/runtime/samples/dynamic-element-action-update/main.svelte b/test/runtime/samples/dynamic-element-action-update/main.svelte new file mode 100644 index 0000000000..1abec7a649 --- /dev/null +++ b/test/runtime/samples/dynamic-element-action-update/main.svelte @@ -0,0 +1,13 @@ + + +tag is {tag}.