mirror of https://github.com/sveltejs/svelte
feat: skip over static subtrees (#12849)
* feat: skip over static subtrees * regenerate * a few more * prettierpull/12846/head
parent
6b6f915f9f
commit
0a06a3f2b6
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat: skip over static subtrees
|
@ -1,10 +1,13 @@
|
|||||||
/** @import { SpreadAttribute } from '#compiler' */
|
/** @import { SpreadAttribute } from '#compiler' */
|
||||||
/** @import { Context } from '../types' */
|
/** @import { Context } from '../types' */
|
||||||
|
|
||||||
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {SpreadAttribute} node
|
* @param {SpreadAttribute} node
|
||||||
* @param {Context} context
|
* @param {Context} context
|
||||||
*/
|
*/
|
||||||
export function SpreadAttribute(node, context) {
|
export function SpreadAttribute(node, context) {
|
||||||
|
mark_subtree_dynamic(context.path);
|
||||||
context.next({ ...context.state, expression: node.metadata.expression });
|
context.next({ ...context.state, expression: node.metadata.expression });
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
/** @import { UseDirective } from '#compiler' */
|
||||||
|
/** @import { Context } from '../types' */
|
||||||
|
import { mark_subtree_dynamic } from './shared/fragment.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {UseDirective} node
|
||||||
|
* @param {Context} context
|
||||||
|
*/
|
||||||
|
export function UseDirective(node, context) {
|
||||||
|
mark_subtree_dynamic(context.path);
|
||||||
|
context.next();
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
/** @import { SvelteNode } from '#compiler' */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SvelteNode[]} path
|
||||||
|
*/
|
||||||
|
export function mark_subtree_dynamic(path) {
|
||||||
|
let i = path.length;
|
||||||
|
while (i--) {
|
||||||
|
const node = path[i];
|
||||||
|
if (node.type === 'Fragment') {
|
||||||
|
if (node.metadata.dynamic) return;
|
||||||
|
node.metadata.dynamic = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
import "svelte/internal/disclose-version";
|
||||||
|
import * as $ from "svelte/internal/client";
|
||||||
|
|
||||||
|
var root = $.template(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header>`);
|
||||||
|
|
||||||
|
export default function Skip_static_subtree($$anchor) {
|
||||||
|
var header = root();
|
||||||
|
|
||||||
|
$.append($$anchor, header);
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
import * as $ from "svelte/internal/server";
|
||||||
|
|
||||||
|
export default function Skip_static_subtree($$payload) {
|
||||||
|
$$payload.out += `<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header>`;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
<header>
|
||||||
|
<nav>
|
||||||
|
<a href="/">Home</a>
|
||||||
|
<a href="/away">Away</a>
|
||||||
|
</nav>
|
||||||
|
</header>
|
Loading…
Reference in new issue