From 8eea6b07c415ac5c7e3a401265e6390f0e18e5b9 Mon Sep 17 00:00:00 2001 From: Evan You Date: Wed, 9 Jan 2019 22:03:51 -0500 Subject: [PATCH] refactor: avoid using immutable object for $slot libs like Avoiraz assumes $slots is mutable, need backwards compat. --- src/core/instance/render-helpers/resolve-slots.js | 3 +-- src/core/vdom/helpers/normalize-scoped-slots.js | 13 +++---------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/core/instance/render-helpers/resolve-slots.js b/src/core/instance/render-helpers/resolve-slots.js index 533b059c..dbec386a 100644 --- a/src/core/instance/render-helpers/resolve-slots.js +++ b/src/core/instance/render-helpers/resolve-slots.js @@ -1,7 +1,6 @@ /* @flow */ import type VNode from 'core/vdom/vnode' -import { emptyObject } from 'core/util/index' /** * Runtime helper for resolving raw children VNodes into a slot object. @@ -11,7 +10,7 @@ export function resolveSlots ( context: ?Component ): { [key: string]: Array } { if (!children || !children.length) { - return emptyObject + return {} } const slots = {} for (let i = 0, l = children.length; i < l; i++) { diff --git a/src/core/vdom/helpers/normalize-scoped-slots.js b/src/core/vdom/helpers/normalize-scoped-slots.js index 12454ebf..239d9a90 100644 --- a/src/core/vdom/helpers/normalize-scoped-slots.js +++ b/src/core/vdom/helpers/normalize-scoped-slots.js @@ -1,16 +1,11 @@ /* @flow */ -import { emptyObject } from 'core/util/index' - export function normalizeScopedSlots ( slots: { [key: string]: Function } | void, normalSlots: { [key: string]: Array } ): any { let res if (!slots) { - if (normalSlots === emptyObject) { - return emptyObject - } res = {} } else if (slots._normalized) { return slots @@ -19,14 +14,12 @@ export function normalizeScopedSlots ( for (const key in slots) { res[key] = normalizeScopedSlot(slots[key]) } - res._normalized = true } // expose normal slots on scopedSlots - if (normalSlots !== emptyObject) { - for (const key in normalSlots) { - res[key] = () => normalSlots[key] - } + for (const key in normalSlots) { + res[key] = () => normalSlots[key] } + res._normalized = true return res }