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. 15
      src/core/instance/render.js

15
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,9 +161,8 @@ 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 (process.env.NODE_ENV !== 'production') { if (slotNodes && 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.`,
@ -164,11 +170,6 @@ export function renderMixin (Vue: Class<Component>) {
) )
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