mirror of https://github.com/sveltejs/svelte
parent
2d97b87c9d
commit
4a0e639732
@ -0,0 +1,40 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
html: `<button>toggle</button><p>before</p><p>after</p>`,
|
||||
|
||||
async test({ target, assert }) {
|
||||
const btn = target.querySelector('button');
|
||||
const ps = target.querySelectorAll('p');
|
||||
|
||||
// @ts-expect-error
|
||||
assert.deepEqual(ps[0].__svelte_meta.loc, {
|
||||
filename: '.../samples/svelte-meta-dynamic/main.svelte',
|
||||
line: 7,
|
||||
column: 0
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
assert.deepEqual(ps[1].__svelte_meta.loc, {
|
||||
filename: '.../samples/svelte-meta-dynamic/main.svelte',
|
||||
line: 13,
|
||||
column: 0
|
||||
});
|
||||
|
||||
flushSync(() => btn?.click());
|
||||
|
||||
const strong = target.querySelector('strong');
|
||||
|
||||
// @ts-expect-error
|
||||
assert.deepEqual(strong.__svelte_meta.loc, {
|
||||
filename: '.../samples/svelte-meta-dynamic/main.svelte',
|
||||
line: 10,
|
||||
column: 1
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
let condition = $state(false);
|
||||
</script>
|
||||
|
||||
<button onclick={() => condition = !condition}>toggle</button>
|
||||
|
||||
<svelte:element this={'p'}>before</svelte:element>
|
||||
|
||||
{#if condition}
|
||||
<svelte:element this={'strong'}>during</svelte:element>
|
||||
{/if}
|
||||
|
||||
<svelte:element this={'p'}>after</svelte:element>
|
||||
Loading…
Reference in new issue