mirror of https://github.com/sveltejs/svelte
[fix] Improve `is_promise` handling (#8162)
* correctly handle promises that are of function type * add License Co-authored-by: Vilsol <me@vil.so>pull/8175/head
parent
e1a1c7fa87
commit
4b84c4df3a
@ -0,0 +1,19 @@
|
|||||||
|
const realPromise = Promise.resolve(42);
|
||||||
|
|
||||||
|
const promise = () => {};
|
||||||
|
promise.then = realPromise.then.bind(realPromise);
|
||||||
|
promise.catch = realPromise.catch.bind(realPromise);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
promise
|
||||||
|
},
|
||||||
|
|
||||||
|
test({ assert, target }) {
|
||||||
|
return promise.then(() => {
|
||||||
|
assert.htmlEqual(target.innerHTML, `
|
||||||
|
<p>42</p>
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
export let promise;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#await promise then value}
|
||||||
|
<p>{JSON.stringify(value)}</p>
|
||||||
|
{/await}
|
Loading…
Reference in new issue