diff --git a/src/runtime/internal/Component.ts b/src/runtime/internal/Component.ts index f0ddc12133..fba7f0faa7 100644 --- a/src/runtime/internal/Component.ts +++ b/src/runtime/internal/Component.ts @@ -1,6 +1,6 @@ import { add_render_callback, flush, schedule_update, dirty_components } from './scheduler'; import { current_component, set_current_component } from './lifecycle'; -import { is_empty, is_function, run, run_all, noop } from './utils'; +import { blank_object, is_empty, is_function, run, run_all, noop } from './utils'; import { children, detach, start_hydrating, end_hydrating } from './dom'; import { transition_in } from './transitions'; @@ -116,7 +116,7 @@ export function init(component, options, instance, create_fragment, not_equal, p props, update: noop, not_equal, - bound: {}, + bound: blank_object(), // lifecycle on_mount: [], @@ -127,7 +127,7 @@ export function init(component, options, instance, create_fragment, not_equal, p context: new Map(options.context || (parent_component ? parent_component.$$.context : [])), // everything else - callbacks: {}, + callbacks: blank_object(), dirty, skip_bound: false, root: options.target || parent_component.$$.root diff --git a/src/runtime/internal/ssr.ts b/src/runtime/internal/ssr.ts index 27c4a47a45..dc4c16dffb 100644 --- a/src/runtime/internal/ssr.ts +++ b/src/runtime/internal/ssr.ts @@ -1,5 +1,5 @@ import { set_current_component, current_component } from './lifecycle'; -import { run_all } from './utils'; +import { run_all, blank_object } from './utils'; import { boolean_attributes } from '../../shared/boolean_attributes'; export { is_void } from '../../shared/utils/names'; @@ -150,7 +150,7 @@ export function create_ssr_component(fn) { on_mount: [], before_update: [], after_update: [], - callbacks: {} + callbacks: blank_object() }; set_current_component({ $$ }); diff --git a/src/runtime/internal/utils.ts b/src/runtime/internal/utils.ts index 24cb5d8b57..c24ee5a7fb 100644 --- a/src/runtime/internal/utils.ts +++ b/src/runtime/internal/utils.ts @@ -24,6 +24,10 @@ export function run(fn) { return fn(); } +export function blank_object() { + return Object.create(null); +} + export function run_all(fns: Function[]) { fns.forEach(run); }