-
Notifications
You must be signed in to change notification settings - Fork 668
/
Copy pathvue-wrapper.js
39 lines (35 loc) · 1.07 KB
/
vue-wrapper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// @flow
import Wrapper from './wrapper'
import addSlots from '../lib/add-slots'
import cloneDeep from 'lodash/cloneDeep'
function update () {
// the only component made by mount()
if (this.$_originalSlots) {
this.$slots = cloneDeep(this.$_originalSlots)
}
if (this.$_mountingOptionsSlots) {
addSlots(this, this.$_mountingOptionsSlots)
}
const vnodes = this._render()
this._update(vnodes)
this.$children.forEach(child => update.call(child))
}
export default class VueWrapper extends Wrapper implements BaseWrapper {
constructor (vm: Component, options: WrapperOptions) {
super(vm._vnode, update.bind(vm), options)
// $FlowIgnore : issue with defineProperty - https://github.com/facebook/flow/issues/285
Object.defineProperty(this, 'vnode', ({
get: () => vm._vnode,
set: () => {}
}))
// $FlowIgnore
Object.defineProperty(this, 'element', ({
get: () => vm.$el,
set: () => {}
}))
this.vm = vm
this.isVueComponent = true
this._emitted = vm.__emitted
this._emittedByOrder = vm.__emittedByOrder
}
}