diff --git a/src/platforms/web/runtime/components/index.js b/src/platforms/web/runtime/components/index.js index d1620c69..185eb3a3 100644 --- a/src/platforms/web/runtime/components/index.js +++ b/src/platforms/web/runtime/components/index.js @@ -1,5 +1,7 @@ +import Transition from './transition' import TransitionControl from './transition-control' export default { + Transition, TransitionControl } diff --git a/src/platforms/web/runtime/components/transition.js b/src/platforms/web/runtime/components/transition.js new file mode 100644 index 00000000..bd2b78e8 --- /dev/null +++ b/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 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 + } + } +}