Skip to content

fix: enable local transitions on svelte:element #12346

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-cows-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: enable local transitions on `svelte:element`
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { current_component_context, current_effect } from '../../runtime.js';
import { DEV } from 'esm-env';
import { assign_nodes } from '../template.js';
import { noop } from '../../../shared/utils.js';
import { EFFECT_TRANSPARENT } from '../../constants.js';

/**
* @param {Comment | Element} node
Expand Down Expand Up @@ -135,5 +136,5 @@ export function element(node, get_tag, is_svg, render_fn, get_namespace, locatio
// Inert effects are proactively detached from the effect tree. Returning a noop
// teardown function is an easy way to ensure that this is not discarded
return noop;
});
}, EFFECT_TRANSPARENT);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { test } from '../../test';
import { flushSync } from 'svelte';

export default test({
async test({ assert, target, raf }) {
const btn = target.querySelector('button');

raf.tick(0);
btn?.click();
flushSync();

assert.htmlEqual(
target.innerHTML,
`<button>Toggle</button> <div style="opacity: 0;">DIV</div>`
);

raf.tick(100);

assert.htmlEqual(target.innerHTML, `<button>Toggle</button> <div style="">DIV</div>`);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import { fade } from 'svelte/transition';
let element = $state('div');
let show = $state(false);
</script>

<button onclick={() => (show = !show)}>Toggle</button>

{#if show}
<svelte:element this={element} transition:fade={{ duration: 100 }}>DIV</svelte:element>
{/if}
Loading