From 12c96764f4d8619bc3b4d3f5d63d500611c21583 Mon Sep 17 00:00:00 2001 From: hackape Date: Wed, 28 Jun 2023 11:08:55 +0800 Subject: [PATCH 1/2] fix #8233 svelte:element local transition not applied --- .changeset/neat-feet-accept.md | 5 +++++ .../compile/render_dom/wrappers/Element/index.js | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 .changeset/neat-feet-accept.md diff --git a/.changeset/neat-feet-accept.md b/.changeset/neat-feet-accept.md new file mode 100644 index 000000000000..4e10fec65d1a --- /dev/null +++ b/.changeset/neat-feet-accept.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: apply transition_in/out to svelte:element with local transition diff --git a/packages/svelte/src/compiler/compile/render_dom/wrappers/Element/index.js b/packages/svelte/src/compiler/compile/render_dom/wrappers/Element/index.js index 5f8def5f2910..b8a09b91af4c 100644 --- a/packages/svelte/src/compiler/compile/render_dom/wrappers/Element/index.js +++ b/packages/svelte/src/compiler/compile/render_dom/wrappers/Element/index.js @@ -233,6 +233,14 @@ export default class ElementWrapper extends Wrapper { strip_whitespace, next_sibling ); + + // in the case of `parent_block -> child_dynamic_element_block -> child_dynamic_element` + // `child_dynamic_element_block.add_intro/outro` is called inside `new ElementWrapper()` + // but when `is_local === true` it does not bubble to parent_block + // we manually add transitions back to the parent_block (#8233) + if (node.intro) block.add_intro(node.intro.is_local); + if (node.outro) block.add_outro(node.outro.is_local); + // the original svelte:element is never used for rendering, because // it gets assigned a child_dynamic_element which is used in all rendering logic. // so doing all of this on the original svelte:element will just cause double @@ -266,10 +274,10 @@ export default class ElementWrapper extends Wrapper { this.event_handlers = this.node.handlers.map( (event_handler) => new EventHandler(event_handler, this) ); - if (node.intro || node.outro) { - if (node.intro) block.add_intro(node.intro.is_local); - if (node.outro) block.add_outro(node.outro.is_local); - } + + if (node.intro) block.add_intro(node.intro.is_local); + if (node.outro) block.add_outro(node.outro.is_local); + if (node.animation) { block.add_animation(); } From 836f2338b21ad51a5ab2399a8837770457f387fb Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Wed, 28 Jun 2023 11:54:29 +0200 Subject: [PATCH 2/2] Update .changeset/neat-feet-accept.md --- .changeset/neat-feet-accept.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/neat-feet-accept.md b/.changeset/neat-feet-accept.md index 4e10fec65d1a..f045be3c2f81 100644 --- a/.changeset/neat-feet-accept.md +++ b/.changeset/neat-feet-accept.md @@ -2,4 +2,4 @@ 'svelte': patch --- -fix: apply transition_in/out to svelte:element with local transition +fix: apply transition to `` with local transition