chore: improve runtime overhead of creating comment templates (#11591)

* chore: improve runtime overhead of creating comment templates

* Update packages/svelte/src/internal/client/dom/template.js

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>

* changeset

---------

Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com>
Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/11592/head
Dominic Gannaway 8 months ago committed by GitHub
parent 965afc5ccc
commit dc16668773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
chore: improve runtime overhead of creating comment templates

@ -251,7 +251,18 @@ export function text(anchor) {
return push_template_node(node); return push_template_node(node);
} }
export const comment = template('<!>', TEMPLATE_FRAGMENT | TEMPLATE_USE_IMPORT_NODE); export function comment() {
// we're not delegating to `template` here for performance reasons
if (hydrating) {
return push_template_node(hydrate_nodes);
}
var frag = document.createDocumentFragment();
var anchor = empty();
frag.append(anchor);
push_template_node([anchor]);
return frag;
}
/** /**
* Assign the created (or in hydration mode, traversed) dom elements to the current block * Assign the created (or in hydration mode, traversed) dom elements to the current block

Loading…
Cancel
Save