Skip to content

Commit

Permalink
refactor: split resolve-scoped-slot into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 6, 2019
1 parent 24b4640 commit b6247fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/core/instance/render-helpers/index.js
Expand Up @@ -9,7 +9,7 @@ import { checkKeyCodes } from './check-keycodes'
import { bindObjectProps } from './bind-object-props'
import { renderStatic, markOnce } from './render-static'
import { bindObjectListeners } from './bind-object-listeners'
import { resolveScopedSlots } from './resolve-slots'
import { resolveScopedSlots } from './resolve-scoped-slots'
import { bindDynamicKeys, prependModifier } from './bind-dynamic-keys'

export function installRenderHelpers (target: any) {
Expand Down
18 changes: 18 additions & 0 deletions src/core/instance/render-helpers/resolve-scoped-slots.js
@@ -0,0 +1,18 @@
/* @flow */

export function resolveScopedSlots (
fns: ScopedSlotsData, // see flow/vnode
hasDynamicKeys?: boolean,
res?: Object
): { [key: string]: Function, $stable: boolean } {
res = res || { $stable: !hasDynamicKeys }
for (let i = 0; i < fns.length; i++) {
const slot = fns[i]
if (Array.isArray(slot)) {
resolveScopedSlots(slot, hasDynamicKeys, res)
} else if (slot) {
res[slot.key] = slot.fn
}
}
return res
}
17 changes: 0 additions & 17 deletions src/core/instance/render-helpers/resolve-slots.js
Expand Up @@ -48,20 +48,3 @@ export function resolveSlots (
function isWhitespace (node: VNode): boolean {
return (node.isComment && !node.asyncFactory) || node.text === ' '
}

export function resolveScopedSlots (
fns: ScopedSlotsData, // see flow/vnode
hasDynamicKeys?: boolean,
res?: Object
): { [key: string]: Function, $stable: boolean } {
res = res || { $stable: !hasDynamicKeys }
for (let i = 0; i < fns.length; i++) {
const slot = fns[i]
if (Array.isArray(slot)) {
resolveScopedSlots(slot, hasDynamicKeys, res)
} else if (slot) {
res[slot.key] = slot.fn
}
}
return res
}

0 comments on commit b6247fc

Please sign in to comment.