pull/15538/head
Rich Harris 4 months ago
parent 7d1551b3dd
commit fa8e1efd5e

@ -236,7 +236,7 @@ export function ns_template(content, flags, ns = 'svg') {
export function ns_template_fn(structure, flags, ns = 'svg') { export function ns_template_fn(structure, flags, ns = 'svg') {
var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0; var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;
/** @type {Element | DocumentFragment} */ /** @type {Node} */
var node; var node;
return () => { return () => {
@ -245,20 +245,9 @@ export function ns_template_fn(structure, flags, ns = 'svg') {
return hydrate_node; return hydrate_node;
} }
if (!node) { if (node === undefined) {
var fragment = structure_to_fragment( node = structure_to_fragment(structure, ns === 'svg' ? NAMESPACE_SVG : NAMESPACE_MATHML);
structure, if (!is_fragment) node = /** @type {Node} */ (get_first_child(node));
ns === 'svg' ? NAMESPACE_SVG : NAMESPACE_MATHML
);
if (is_fragment) {
node = document.createDocumentFragment();
while (get_first_child(fragment)) {
node.appendChild(/** @type {Node} */ (get_first_child(fragment)));
}
} else {
node = /** @type {Element} */ (get_first_child(fragment));
}
} }
var clone = /** @type {TemplateNode} */ (node.cloneNode(true)); var clone = /** @type {TemplateNode} */ (node.cloneNode(true));

Loading…
Cancel
Save