Skip to content

Commit 8eea6b0

Browse files
committed
refactor: avoid using immutable object for $slot
libs like Avoiraz assumes $slots is mutable, need backwards compat.
1 parent 3be1c5d commit 8eea6b0

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

Diff for: src/core/instance/render-helpers/resolve-slots.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* @flow */
22

33
import type VNode from 'core/vdom/vnode'
4-
import { emptyObject } from 'core/util/index'
54

65
/**
76
* Runtime helper for resolving raw children VNodes into a slot object.
@@ -11,7 +10,7 @@ export function resolveSlots (
1110
context: ?Component
1211
): { [key: string]: Array<VNode> } {
1312
if (!children || !children.length) {
14-
return emptyObject
13+
return {}
1514
}
1615
const slots = {}
1716
for (let i = 0, l = children.length; i < l; i++) {

Diff for: src/core/vdom/helpers/normalize-scoped-slots.js

+3-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
/* @flow */
22

3-
import { emptyObject } from 'core/util/index'
4-
53
export function normalizeScopedSlots (
64
slots: { [key: string]: Function } | void,
75
normalSlots: { [key: string]: Array<VNode> }
86
): any {
97
let res
108
if (!slots) {
11-
if (normalSlots === emptyObject) {
12-
return emptyObject
13-
}
149
res = {}
1510
} else if (slots._normalized) {
1611
return slots
@@ -19,14 +14,12 @@ export function normalizeScopedSlots (
1914
for (const key in slots) {
2015
res[key] = normalizeScopedSlot(slots[key])
2116
}
22-
res._normalized = true
2317
}
2418
// expose normal slots on scopedSlots
25-
if (normalSlots !== emptyObject) {
26-
for (const key in normalSlots) {
27-
res[key] = () => normalSlots[key]
28-
}
19+
for (const key in normalSlots) {
20+
res[key] = () => normalSlots[key]
2921
}
22+
res._normalized = true
3023
return res
3124
}
3225

0 commit comments

Comments
 (0)