Evan You 8 years ago
parent
commit
d960dfead8
  1. 2
      src/platforms/web/runtime/components/index.js
  2. 28
      src/platforms/web/runtime/components/transition.js

2
src/platforms/web/runtime/components/index.js

@ -1,5 +1,7 @@
import Transition from './transition'
import TransitionControl from './transition-control'
export default {
Transition,
TransitionControl
}

28
src/platforms/web/runtime/components/transition.js

@ -0,0 +1,28 @@
// import { emptyVNode } from 'core/vdom/vnode'
export default {
name: 'transition',
props: ['name', 'appear', 'tag'],
_abstract: true,
render (h) {
const children = this.$slots.default
const props = this.$options.propsData
if (!children || !children.length) {
return
}
for (let i = 0; i < children.length; i++) {
const child = children[i]
;(child.data || (child.data = {})).transition = props
}
if (children.length > 1) {
if (!props.tag) {
throw new Error('prop "tag" is required when <transition> contains more than one element.')
}
return h(props.tag, this.$vnode.data, children)
} else {
const child = children[0]
child.key = child.key || `__v${this._uid}__`
return child
}
}
}
Loading…
Cancel
Save