-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure if block is executed in correct order (#10053)
* fix: ensure if block is executed in correct order * alternative approach * improve algo * optimize * lint
- Loading branch information
Showing
5 changed files
with
120 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure if block is executed in correct order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/svelte/tests/runtime-runes/samples/block-dependency-sequence/Component.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script> | ||
const { item } = $props(); | ||
</script> | ||
|
||
<div> | ||
{#if item} | ||
{item.length} | ||
{/if} | ||
</div> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/block-dependency-sequence/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
async test({ assert, target, component }) { | ||
const [b1, b2] = target.querySelectorAll('button'); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<div>5</div><div>5</div><div>3</div><button>set null</button><button>set object</button' | ||
); | ||
flushSync(() => { | ||
b2.click(); | ||
}); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<div>5</div><div>5</div><div>3</div><button>set null</button><button>set object</button' | ||
); | ||
flushSync(() => { | ||
b1.click(); | ||
}); | ||
assert.htmlEqual( | ||
target.innerHTML, | ||
'<div>5</div><div></div><div>3</div><button>set null</button><button>set object</button' | ||
); | ||
} | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/svelte/tests/runtime-runes/samples/block-dependency-sequence/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script> | ||
import Component from './Component.svelte'; | ||
let items = $state(['hello', 'world', 'bye']); | ||
</script> | ||
|
||
{#each items as item} | ||
<Component {item} /> | ||
{/each} | ||
|
||
<button onclick={() => (items[1] = null)}> set null </button> | ||
<button onclick={() => (items[1] = 'hello')}> set object </button> |
1e33ed5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
svelte-5-preview – ./sites/svelte-5-preview
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview-svelte.vercel.app