mirror of https://github.com/sveltejs/svelte
				
				
				
			chore: remove metadata.pending (#16764)
	
		
	
				
					
				
			
							parent
							
								
									2365d1b90c
								
							
						
					
					
						commit
						33453869e7
					
				@ -1,36 +1,36 @@
 | 
				
			|||||||
/** @import { BlockStatement } from 'estree' */
 | 
					/** @import { BlockStatement } from 'estree' */
 | 
				
			||||||
/** @import { AST } from '#compiler' */
 | 
					/** @import { AST } from '#compiler' */
 | 
				
			||||||
/** @import { ComponentContext } from '../types' */
 | 
					/** @import { ComponentContext } from '../types' */
 | 
				
			||||||
import {
 | 
					 | 
				
			||||||
	BLOCK_CLOSE,
 | 
					 | 
				
			||||||
	BLOCK_OPEN,
 | 
					 | 
				
			||||||
	BLOCK_OPEN_ELSE
 | 
					 | 
				
			||||||
} from '../../../../../internal/server/hydration.js';
 | 
					 | 
				
			||||||
import * as b from '#compiler/builders';
 | 
					import * as b from '#compiler/builders';
 | 
				
			||||||
import { build_attribute_value } from './shared/utils.js';
 | 
					import { block_close, block_open, block_open_else, build_attribute_value } from './shared/utils.js';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * @param {AST.SvelteBoundary} node
 | 
					 * @param {AST.SvelteBoundary} node
 | 
				
			||||||
 * @param {ComponentContext} context
 | 
					 * @param {ComponentContext} context
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function SvelteBoundary(node, context) {
 | 
					export function SvelteBoundary(node, context) {
 | 
				
			||||||
	const pending_snippet = node.metadata.pending;
 | 
						// if this has a `pending` snippet, render it
 | 
				
			||||||
 | 
						const pending_attribute = /** @type {AST.Attribute} */ (
 | 
				
			||||||
 | 
							node.attributes.find((node) => node.type === 'Attribute' && node.name === 'pending')
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (pending_snippet) {
 | 
						const pending_snippet = /** @type {AST.SnippetBlock} */ (
 | 
				
			||||||
		context.state.template.push(b.literal(BLOCK_OPEN_ELSE));
 | 
							node.fragment.nodes.find(
 | 
				
			||||||
 | 
								(node) => node.type === 'SnippetBlock' && node.expression.name === 'pending'
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
 | 
						);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (pending_snippet.type === 'Attribute') {
 | 
						if (pending_attribute || pending_snippet) {
 | 
				
			||||||
			const value = build_attribute_value(pending_snippet.value, context, false, true);
 | 
							const pending = pending_attribute
 | 
				
			||||||
			context.state.template.push(b.call(value, b.id('$$payload')));
 | 
								? b.call(
 | 
				
			||||||
		} else if (pending_snippet.type === 'SnippetBlock') {
 | 
										build_attribute_value(pending_attribute.value, context, false, true),
 | 
				
			||||||
			context.state.template.push(
 | 
										b.id('$$payload')
 | 
				
			||||||
				/** @type {BlockStatement} */ (context.visit(pending_snippet.body))
 | 
									)
 | 
				
			||||||
			);
 | 
								: /** @type {BlockStatement} */ (context.visit(pending_snippet.body));
 | 
				
			||||||
		}
 | 
					
 | 
				
			||||||
 | 
							context.state.template.push(block_open_else, pending, block_close);
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		context.state.template.push(b.literal(BLOCK_OPEN));
 | 
							const block = /** @type {BlockStatement} */ (context.visit(node.fragment));
 | 
				
			||||||
		context.state.template.push(/** @type {BlockStatement} */ (context.visit(node.fragment)));
 | 
							context.state.template.push(block_open, block, block_close);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					 | 
				
			||||||
	context.state.template.push(b.literal(BLOCK_CLOSE));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
					Loading…
					
					
				
		Reference in new issue