mirror of https://github.com/sveltejs/svelte
feat: skip static nodes (#12914)
* step one * WIP * more * fix * collapse sequential sibling calls * working * working but messy * tidy up * unused * tweak * tweak * tidy * tweak * tweak * revert * changeset * Update packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/fragment.js Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> * revert this bit * align * comments --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>pull/12922/head
parent
b2214d1c5b
commit
23bce2da20
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: skip over static nodes in compiled client code
|
@ -1,10 +1,20 @@
|
||||
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>`);
|
||||
var root = $.template(`<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1> </h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> <!></main>`, 1);
|
||||
|
||||
export default function Skip_static_subtree($$anchor) {
|
||||
var header = root();
|
||||
export default function Skip_static_subtree($$anchor, $$props) {
|
||||
var fragment = root();
|
||||
var main = $.sibling($.first_child(fragment), 2);
|
||||
var h1 = $.child(main);
|
||||
var text = $.child(h1);
|
||||
|
||||
$.append($$anchor, header);
|
||||
$.reset(h1);
|
||||
|
||||
var node = $.sibling(h1, 10);
|
||||
|
||||
$.html(node, () => $$props.content, false, false);
|
||||
$.reset(main);
|
||||
$.template_effect(() => $.set_text(text, $$props.title));
|
||||
$.append($$anchor, fragment);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
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>`;
|
||||
export default function Skip_static_subtree($$payload, $$props) {
|
||||
let { title, content } = $$props;
|
||||
|
||||
$$payload.out += `<header><nav><a href="/">Home</a> <a href="/away">Away</a></nav></header> <main><h1>${$.escape(title)}</h1> <div class="static"><p>we don't need to traverse these nodes</p></div> <p>or</p> <p>these</p> <p>ones</p> ${$.html(content)}</main>`;
|
||||
}
|
@ -1,6 +1,21 @@
|
||||
<script>
|
||||
let { title, content } = $props();
|
||||
</script>
|
||||
|
||||
<header>
|
||||
<nav>
|
||||
<a href="/">Home</a>
|
||||
<a href="/away">Away</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<h1>{title}</h1>
|
||||
<div class="static">
|
||||
<p>we don't need to traverse these nodes</p>
|
||||
</div>
|
||||
<p>or</p>
|
||||
<p>these</p>
|
||||
<p>ones</p>
|
||||
{@html content}
|
||||
</main>
|
||||
|
Loading…
Reference in new issue