spread is faster than Array.from

pull/10896/head
Rich Harris 2 years ago
parent a008a9b09e
commit 7230fbe83b

@ -93,7 +93,7 @@ export function reconcile_html(target, value, svg) {
content = /** @type {DocumentFragment} */ (/** @type {unknown} */ (content.firstChild)); content = /** @type {DocumentFragment} */ (/** @type {unknown} */ (content.firstChild));
} }
var clone = content.cloneNode(true); var clone = content.cloneNode(true);
frag_nodes = Array.from(clone.childNodes); frag_nodes = [...clone.childNodes];
frag_nodes.forEach((node) => { frag_nodes.forEach((node) => {
target.before(node); target.before(node);
}); });

@ -182,7 +182,7 @@ function close_template(dom, is_fragment, anchor) {
if (is_fragment) { if (is_fragment) {
// if hydrating, `dom` is already an array of nodes, but if not then // if hydrating, `dom` is already an array of nodes, but if not then
// we need to create an array to store it on the current effect // we need to create an array to store it on the current effect
dom = /** @type {import('#client').Dom} */ (Array.from(/** @type {Node} */ (dom).childNodes)); dom = /** @type {import('#client').Dom} */ ([.../** @type {Node} */ (dom).childNodes]);
} }
if (anchor !== null) { if (anchor !== null) {

Loading…
Cancel
Save