(Vue)
| 2014 | } |
| 2015 | |
| 2016 | function lifecycleMixin (Vue) { |
| 2017 | Vue.prototype._update = function (vnode, hydrating) { |
| 2018 | var vm = this; |
| 2019 | if (vm._isMounted) { |
| 2020 | callHook(vm, 'beforeUpdate'); |
| 2021 | } |
| 2022 | var prevEl = vm.$el; |
| 2023 | var prevVnode = vm._vnode; |
| 2024 | var prevActiveInstance = activeInstance; |
| 2025 | activeInstance = vm; |
| 2026 | vm._vnode = vnode; |
| 2027 | // Vue.prototype.__patch__ is injected in entry points |
| 2028 | // based on the rendering backend used. |
| 2029 | if (!prevVnode) { |
| 2030 | // initial render |
| 2031 | vm.$el = vm.__patch__( |
| 2032 | vm.$el, vnode, hydrating, false /* removeOnly */, |
| 2033 | vm.$options._parentElm, |
| 2034 | vm.$options._refElm |
| 2035 | ); |
| 2036 | } else { |
| 2037 | // updates |
| 2038 | vm.$el = vm.__patch__(prevVnode, vnode); |
| 2039 | } |
| 2040 | activeInstance = prevActiveInstance; |
| 2041 | // update __vue__ reference |
| 2042 | if (prevEl) { |
| 2043 | prevEl.__vue__ = null; |
| 2044 | } |
| 2045 | if (vm.$el) { |
| 2046 | vm.$el.__vue__ = vm; |
| 2047 | } |
| 2048 | // if parent is an HOC, update its $el as well |
| 2049 | if (vm.$vnode && vm.$parent && vm.$vnode === vm.$parent._vnode) { |
| 2050 | vm.$parent.$el = vm.$el; |
| 2051 | } |
| 2052 | // updated hook is called by the scheduler to ensure that children are |
| 2053 | // updated in a parent's updated hook. |
| 2054 | }; |
| 2055 | |
| 2056 | Vue.prototype.$forceUpdate = function () { |
| 2057 | var vm = this; |
| 2058 | if (vm._watcher) { |
| 2059 | vm._watcher.update(); |
| 2060 | } |
| 2061 | }; |
| 2062 | |
| 2063 | Vue.prototype.$destroy = function () { |
| 2064 | var vm = this; |
| 2065 | if (vm._isBeingDestroyed) { |
| 2066 | return |
| 2067 | } |
| 2068 | callHook(vm, 'beforeDestroy'); |
| 2069 | vm._isBeingDestroyed = true; |
| 2070 | // remove self from parent |
| 2071 | var parent = vm.$parent; |
| 2072 | if (parent && !parent._isBeingDestroyed && !vm.$options.abstract) { |
| 2073 | remove(parent.$children, vm); |
no test coverage detected