Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eighty-lizards-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

chore: improve runtime overhead of creating comment templates
13 changes: 12 additions & 1 deletion packages/svelte/src/internal/client/dom/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,18 @@ export function text(anchor) {
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
Expand Down