-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix not passing child_ctx for catch block
- Loading branch information
Showing
7 changed files
with
179 additions
and
2 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
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,7 @@ | ||
<script> | ||
export let count; | ||
export let value; | ||
</script> | ||
|
||
<div>count: {count}</div> | ||
<div>value: {value}</div> |
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,64 @@ | ||
export default { | ||
props: { | ||
thePromise: new Promise((_) => {}), | ||
count: 0, | ||
}, | ||
|
||
html: ` | ||
<div><p>loading...</p></div> | ||
`, | ||
|
||
async test({ assert, component, target }) { | ||
await (component.thePromise = Promise.resolve({ value: "success", Component: component.Component })); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Resolved: | ||
<div>count: 0</div> | ||
<div>value: success</div> | ||
</div> | ||
` | ||
); | ||
|
||
component.count = 5; | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Resolved: | ||
<div>count: 5</div> | ||
<div>value: success</div> | ||
</div> | ||
` | ||
); | ||
|
||
try { | ||
await (component.thePromise = Promise.reject({ value: "failure", Component: component.Component })); | ||
} catch { | ||
// ignore | ||
} | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Rejected: | ||
<div>count: 5</div> | ||
<div>value: failure</div> | ||
</div> | ||
` | ||
); | ||
|
||
component.count = 10; | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Rejected: | ||
<div>count: 10</div> | ||
<div>value: failure</div> | ||
</div> | ||
` | ||
); | ||
}, | ||
}; |
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,16 @@ | ||
<script> | ||
import Component from './Component.svelte'; | ||
export let thePromise; | ||
export let count; | ||
export { Component } | ||
</script> | ||
|
||
<div> | ||
{#await thePromise} | ||
<p>loading...</p> | ||
{:then { value: theValue, Component }} | ||
Resolved: <svelte:component this={Component} {count} value={theValue} /> | ||
{:catch { value: theError, Component } } | ||
Rejected: <svelte:component this={Component} {count} value={theError} /> | ||
{/await} | ||
</div> |
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 @@ | ||
<script> | ||
export let count; | ||
</script> | ||
|
||
<div>count: {count}</div> |
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,60 @@ | ||
export default { | ||
props: { | ||
thePromise: new Promise((_) => {}), | ||
count: 0, | ||
}, | ||
|
||
html: ` | ||
<div><p>loading...</p></div> | ||
`, | ||
|
||
async test({ assert, component, target }) { | ||
await (component.thePromise = Promise.resolve(component.Component)); | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Resolved: | ||
<div>count: 0</div> | ||
</div> | ||
` | ||
); | ||
|
||
component.count = 5; | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Resolved: | ||
<div>count: 5</div> | ||
</div> | ||
` | ||
); | ||
|
||
try { | ||
await (component.thePromise = Promise.reject(component.Component)); | ||
} catch { | ||
// ignore | ||
} | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Rejected: | ||
<div>count: 5</div> | ||
</div> | ||
` | ||
); | ||
|
||
component.count = 10; | ||
|
||
assert.htmlEqual( | ||
target.innerHTML, | ||
` | ||
<div>Rejected: | ||
<div>count: 10</div> | ||
</div> | ||
` | ||
); | ||
}, | ||
}; |
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,16 @@ | ||
<script> | ||
import Component from './Component.svelte'; | ||
export let thePromise; | ||
export let count; | ||
export { Component } | ||
</script> | ||
|
||
<div> | ||
{#await thePromise} | ||
<p>loading...</p> | ||
{:then theValue} | ||
Resolved: <svelte:component this={theValue} {count} /> | ||
{:catch theError} | ||
Rejected: <svelte:component this={theError} {count} /> | ||
{/await} | ||
</div> |