Browse Source

move slot cloning back to render function so that it works for jsx as well

dev
Evan You 8 years ago
parent
commit
100a2969aa
  1. 29
      src/core/instance/render.js

29
src/core/instance/render.js

@ -36,6 +36,13 @@ export function renderMixin (Vue: Class<Component>) {
_parentVnode _parentVnode
} = vm.$options } = vm.$options
if (vm._isMounted) {
// clone slot nodes on re-renders
for (const key in vm.$slots) {
vm.$slots[key] = cloneVNodes(vm.$slots[key])
}
}
if (staticRenderFns && !vm._staticTrees) { if (staticRenderFns && !vm._staticTrees) {
vm._staticTrees = [] vm._staticTrees = []
} }
@ -154,20 +161,14 @@ export function renderMixin (Vue: Class<Component>) {
fallback: ?Array<VNode> fallback: ?Array<VNode>
): ?Array<VNode> { ): ?Array<VNode> {
let slotNodes = this.$slots[name] let slotNodes = this.$slots[name]
if (slotNodes) { // warn duplicate slot usage
// warn duplicate slot usage if (slotNodes && process.env.NODE_ENV !== 'production') {
if (process.env.NODE_ENV !== 'production') { slotNodes._rendered && warn(
slotNodes._rendered && warn( `Duplicate presense of slot "${name}" found in the same render tree ` +
`Duplicate presense of slot "${name}" found in the same render tree ` + `- this will likely cause render errors.`,
`- this will likely cause render errors.`, this
this )
) slotNodes._rendered = true
slotNodes._rendered = true
}
// clone slot nodes on re-renders
if (this._isMounted) {
slotNodes = cloneVNodes(slotNodes)
}
} }
return slotNodes || fallback return slotNodes || fallback
} }

Loading…
Cancel
Save