From 1157cee42adedda5f289f7e4db33c21ee8363695 Mon Sep 17 00:00:00 2001 From: pushkine Date: Thu, 28 May 2020 16:25:22 +0200 Subject: [PATCH] fix --- src/runtime/internal/Component.ts | 10 +--------- src/runtime/internal/dom.ts | 4 +++- src/runtime/internal/spread.ts | 17 ++++++++--------- src/runtime/internal/ssr.ts | 2 +- src/runtime/internal/utils.ts | 4 +++- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index ccec235c8d..7dbe27d681 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -44,14 +44,6 @@ export function bind(component, name, callback) { } } -export function create_component(block) { - block && block.c(); -} - -export function claim_component(block, parent_nodes) { - block && block.l(parent_nodes); -} - export function mount_component(component, target, anchor) { const { fragment, on_mount, on_destroy, after_update } = component.$$; @@ -139,7 +131,7 @@ export function init(component, options, instance, create_fragment, not_equal, p $$.update(); ready = true; - $$.before_update.forEach(v => v()); + for (let i = 0, { before_update } = $$; i < before_update.length; i++) before_update[i](); // `false` as a special case of no DOM component $$.fragment = create_fragment ? create_fragment($$.ctx) : false; diff --git a/src/runtime/internal/dom.ts b/src/runtime/internal/dom.ts index 677afa5a24..3a03b27c38 100644 --- a/src/runtime/internal/dom.ts +++ b/src/runtime/internal/dom.ts @@ -1,3 +1,5 @@ +import { has_prop } from "./utils"; + export function append(target: Node, node: Node) { target.appendChild(node); } @@ -27,7 +29,7 @@ export function element_is(name: K, is: s export function object_without_properties(obj: T, excluded: K) { const target = {} as Pick>; let key; - for (key in obj) if (!~excluded.indexOf(key)) target[key] = obj[key]; + for (key in obj) if (has_prop(obj, key) && !~excluded.indexOf(key)) target[key] = obj[key]; return target; } diff --git a/src/runtime/internal/spread.ts b/src/runtime/internal/spread.ts index 6006b327ce..aa730b4465 100644 --- a/src/runtime/internal/spread.ts +++ b/src/runtime/internal/spread.ts @@ -4,17 +4,16 @@ export function get_spread_update(levels, updates) { const to_null_out = {}; const accounted_for = { $$scope: 1 }; - let i = levels.length; + let i = levels.length, + key, + n; while (i--) { - const o = levels[i]; - const n = updates[i]; - - if (n) { - for (const key in o) { + if (n = updates[i]) { + for (key in levels[i]) { if (!(key in n)) to_null_out[key] = 1; } - for (const key in n) { + for (key in n) { if (!accounted_for[key]) { update[key] = n[key]; accounted_for[key] = 1; @@ -23,13 +22,13 @@ export function get_spread_update(levels, updates) { levels[i] = n; } else { - for (const key in o) { + for (key in levels[i]) { accounted_for[key] = 1; } } } - for (const key in to_null_out) { + for ( key in to_null_out) { if (!(key in update)) update[key] = undefined; } diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 459905fc3b..e2ee1fd540 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -101,7 +101,7 @@ export function create_ssr_component(fn) { const html = $$render(result, props, {}, options); - on_destroy.forEach(v => v()); + for (let i = 0; i < on_destroy.length; i++) on_destroy[i](); return { html, diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 4c2ff415ca..26e8d9f258 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -32,4 +32,6 @@ export function subscribe(store, ...callbacks) { export function set_store_value(store, ret, value = ret) { store.set(value); return ret; -} \ No newline at end of file +} + +export const has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); \ No newline at end of file