Skip to content

Commit 876f894

Browse files
authored
fix: apply transition_in/out to svelte:element with local transition (#8865)
fixes #8233
1 parent 1c7ed55 commit 876f894

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.changeset/neat-feet-accept.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: apply transition to `<svelte:element>` with local transition

packages/svelte/src/compiler/compile/render_dom/wrappers/Element/index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ export default class ElementWrapper extends Wrapper {
233233
strip_whitespace,
234234
next_sibling
235235
);
236+
237+
// in the case of `parent_block -> child_dynamic_element_block -> child_dynamic_element`
238+
// `child_dynamic_element_block.add_intro/outro` is called inside `new ElementWrapper()`
239+
// but when `is_local === true` it does not bubble to parent_block
240+
// we manually add transitions back to the parent_block (#8233)
241+
if (node.intro) block.add_intro(node.intro.is_local);
242+
if (node.outro) block.add_outro(node.outro.is_local);
243+
236244
// the original svelte:element is never used for rendering, because
237245
// it gets assigned a child_dynamic_element which is used in all rendering logic.
238246
// so doing all of this on the original svelte:element will just cause double
@@ -266,10 +274,10 @@ export default class ElementWrapper extends Wrapper {
266274
this.event_handlers = this.node.handlers.map(
267275
(event_handler) => new EventHandler(event_handler, this)
268276
);
269-
if (node.intro || node.outro) {
270-
if (node.intro) block.add_intro(node.intro.is_local);
271-
if (node.outro) block.add_outro(node.outro.is_local);
272-
}
277+
278+
if (node.intro) block.add_intro(node.intro.is_local);
279+
if (node.outro) block.add_outro(node.outro.is_local);
280+
273281
if (node.animation) {
274282
block.add_animation();
275283
}

0 commit comments

Comments
 (0)