Skip to content

Commit fa8e1ef

Browse files
committed
simplify
1 parent 7d1551b commit fa8e1ef

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export function ns_template(content, flags, ns = 'svg') {
236236
export function ns_template_fn(structure, flags, ns = 'svg') {
237237
var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;
238238

239-
/** @type {Element | DocumentFragment} */
239+
/** @type {Node} */
240240
var node;
241241

242242
return () => {
@@ -245,20 +245,9 @@ export function ns_template_fn(structure, flags, ns = 'svg') {
245245
return hydrate_node;
246246
}
247247

248-
if (!node) {
249-
var fragment = structure_to_fragment(
250-
structure,
251-
ns === 'svg' ? NAMESPACE_SVG : NAMESPACE_MATHML
252-
);
253-
254-
if (is_fragment) {
255-
node = document.createDocumentFragment();
256-
while (get_first_child(fragment)) {
257-
node.appendChild(/** @type {Node} */ (get_first_child(fragment)));
258-
}
259-
} else {
260-
node = /** @type {Element} */ (get_first_child(fragment));
261-
}
248+
if (node === undefined) {
249+
node = structure_to_fragment(structure, ns === 'svg' ? NAMESPACE_SVG : NAMESPACE_MATHML);
250+
if (!is_fragment) node = /** @type {Node} */ (get_first_child(node));
262251
}
263252

264253
var clone = /** @type {TemplateNode} */ (node.cloneNode(true));

0 commit comments

Comments
 (0)