Merge branch 'effect-pending-value' into effect-pending-value-2

pull/16926/head
Simon H 11 months ago committed by GitHub
commit 3c4dd34a6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -24,6 +24,8 @@ export interface ClientTransformState extends TransformState {
/** `true` if we're transforming the contents of `<script>` */
readonly is_instance: boolean;
effect_pending: Map<Expression, Identifier>;
readonly transform: Record<
string,
{

@ -68,6 +68,7 @@ export function Fragment(node, context) {
memoizer: new Memoizer(),
template: new Template(),
transform: { ...context.state.transform },
effect_pending: new Map(),
metadata: {
namespace,
bound_contenteditable: context.state.metadata.bound_contenteditable
@ -152,6 +153,10 @@ export function Fragment(node, context) {
body.push(...state.consts);
for (const [expression, id] of state.effect_pending) {
body.push(b.const(id, b.call('$.pending', b.thunk(expression))));
}
if (has_await) {
body.push(b.if(b.call('$.aborted'), b.return()));
}

@ -310,7 +310,8 @@ export function RegularElement(node, context) {
metadata,
scope: /** @type {Scope} */ (context.state.scopes.get(node.fragment)),
preserve_whitespace:
context.state.preserve_whitespace || node.name === 'pre' || node.name === 'textarea'
context.state.preserve_whitespace || node.name === 'pre' || node.name === 'textarea',
effect_pending: new Map()
};
const { hoisted, trimmed } = clean_nodes(
@ -378,6 +379,10 @@ export function RegularElement(node, context) {
}
}
for (const [expression, id] of state.effect_pending) {
child_state.init.push(b.const(id, b.call('$.pending', b.thunk(expression))));
}
if (node.fragment.nodes.some((node) => node.type === 'SnippetBlock')) {
// Wrap children in `{...}` to avoid declaration conflicts
context.state.init.push(

@ -57,6 +57,7 @@ export namespace AST {
*/
dynamic: boolean;
has_await: boolean;
effect_pending_expressions: Expression[];
};
}

Loading…
Cancel
Save