mirror of https://github.com/sveltejs/svelte
commit
aac227d6bc
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: add $effect.root rune
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
'svelte': minor
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: support type definition in {@const}
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: improve `<svelte:element>` generated code
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: prevent some unused variable creation
|
@ -0,0 +1,32 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
get props() {
|
||||
return { log: [] };
|
||||
},
|
||||
|
||||
async test({ assert, target, component }) {
|
||||
const [b1, b2, b3] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
b2.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(component.log, [0, 1]);
|
||||
|
||||
flushSync(() => {
|
||||
b3.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(component.log, [0, 1, 'cleanup 1', 'cleanup 2']);
|
||||
|
||||
flushSync(() => {
|
||||
b1.click();
|
||||
b2.click();
|
||||
});
|
||||
|
||||
assert.deepEqual(component.log, [0, 1, 'cleanup 1', 'cleanup 2']);
|
||||
}
|
||||
});
|
@ -0,0 +1,27 @@
|
||||
<script>
|
||||
let { log} = $props();
|
||||
|
||||
let x = $state(0);
|
||||
let y = $state(0);
|
||||
|
||||
const cleanup = $effect.root(() => {
|
||||
$effect(() => {
|
||||
log.push(x);
|
||||
});
|
||||
|
||||
const nested_cleanup = $effect.root(() => {
|
||||
return () => {
|
||||
log.push('cleanup 2') ;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
log.push('cleanup 1');
|
||||
nested_cleanup();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<button on:click={() => x++}>{x}</button>
|
||||
<button on:click={() => y++}>{y}</button>
|
||||
<button on:click={() => cleanup()}>cleanup</button>
|
@ -0,0 +1,3 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({});
|
@ -0,0 +1,17 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import "svelte/internal/disclose-version";
|
||||
import * as $ from "svelte/internal";
|
||||
|
||||
export default function Svelte_element($$anchor, $$props) {
|
||||
$.push($$props, true);
|
||||
|
||||
let tag = $.prop_source($$props, "tag", 'hr', false);
|
||||
/* Init */
|
||||
var fragment = $.comment($$anchor);
|
||||
var node = $.child_frag(fragment);
|
||||
|
||||
$.element(node, () => $.get(tag));
|
||||
$.close_frag($$anchor, fragment);
|
||||
$.pop();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
// index.svelte (Svelte VERSION)
|
||||
// Note: compiler output will change before 5.0 is released!
|
||||
import * as $ from "svelte/internal/server";
|
||||
|
||||
export default function Svelte_element($$payload, $$props) {
|
||||
$.push(true);
|
||||
|
||||
let { tag = 'hr' } = $$props;
|
||||
const anchor = $.create_anchor($$payload);
|
||||
|
||||
$$payload.out += `${anchor}`;
|
||||
|
||||
if (tag) {
|
||||
const anchor_1 = $.create_anchor($$payload);
|
||||
|
||||
$$payload.out += `<${tag}>`;
|
||||
|
||||
if (!$.VoidElements.has(tag)) {
|
||||
$$payload.out += `${anchor_1}`;
|
||||
$$payload.out += `${anchor_1}</${tag}>`;
|
||||
}
|
||||
}
|
||||
|
||||
$$payload.out += `${anchor}`;
|
||||
$.bind_props($$props, { tag });
|
||||
$.pop();
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { tag = 'hr' } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:element this={tag} />
|
Loading…
Reference in new issue