-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get context at start of {#if} update block instead of at the end (#5531)
- Loading branch information
1 parent
f038cf7
commit a4e4bd0
Showing
3 changed files
with
49 additions
and
1 deletion.
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
29 changes: 29 additions & 0 deletions
29
test/runtime/samples/await-then-destruct-object-if/_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,29 @@ | ||
export default { | ||
props: { | ||
thePromise: Promise.resolve({ result: 1 }) | ||
}, | ||
|
||
html: '', | ||
|
||
async test({ assert, component, target }) { | ||
await (component.thePromise = Promise.resolve({ result: 1 })); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<p>result: 1</p> | ||
<p>count: 0</p> | ||
` | ||
); | ||
|
||
await new Promise(resolve => setTimeout(resolve, 1)); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<p>result: 1</p> | ||
<p>count: 1</p> | ||
` | ||
); | ||
} | ||
}; |
19 changes: 19 additions & 0 deletions
19
test/runtime/samples/await-then-destruct-object-if/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,19 @@ | ||
<script> | ||
export let thePromise; | ||
let count = 0; | ||
setTimeout(() => { | ||
count++; | ||
}, 0); | ||
</script> | ||
|
||
{#await thePromise then { result }} | ||
{#if result} | ||
<p>result: {result}</p> | ||
<p>count: {count}</p> | ||
{:else} | ||
<p>result: {result}</p> | ||
<p>count: {count}</p> | ||
{/if} | ||
{/await} |