fix: allow `$props.id()` to occur after an `await` (#17285)

pull/17287/head
Rich Harris 5 months ago committed by GitHub
parent f8287b0d91
commit 0e1c98ea11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow `$props.id()` to occur after an `await`

@ -1105,6 +1105,11 @@ function calculate_blockers(instance, scopes, analysis) {
functions.push(node);
} else if (node.type === 'VariableDeclaration') {
for (const declarator of node.declarations) {
if (get_rune(declarator.init, instance.scope) === '$props.id') {
// special case
continue;
}
if (
declarator.init?.type === 'ArrowFunctionExpression' ||
declarator.init?.type === 'FunctionExpression'

@ -0,0 +1,11 @@
import { tick } from 'svelte';
import { test } from '../../test';
export default test({
ssrHtml: `<p>s1</p>`,
async test({ assert, target, variant }) {
await tick();
assert.htmlEqual(target.innerHTML, variant === 'hydrate' ? '<p>s1</p>' : '<p>c1</p>');
}
});

@ -0,0 +1,6 @@
<script>
await 1
const id = $props.id();
</script>
<p>{id}</p>
Loading…
Cancel
Save