UNPKG

cheetah-framework

Version:

Cheetah Framework JS used in all our applications

54 lines (41 loc) 1.27 kB
import Vue from 'vue' export default { removeLifeCycle (vueObject) { const clonedVueObject = _.clone(vueObject) delete clonedVueObject.beforeCreate delete clonedVueObject.created delete clonedVueObject.beforeMount delete clonedVueObject.mounted delete clonedVueObject.beforeUpdate delete clonedVueObject.updated delete clonedVueObject.beforeDestroy delete clonedVueObject.destroyed return clonedVueObject }, extend (extendedComponent, newComponent) { extendedComponent.methods = _.extend(extendedComponent.methods, newComponent.methods) extendedComponent.computed = _.extend(extendedComponent.computed, newComponent.computed) addExtendedComponentMixin(extendedComponent, newComponent) return Vue.extend({ mixins: [ this.removeLifeCycle(extendedComponent), newComponent, ] }) }, mergeArrayOptions (toVal, fromVal) { if (!fromVal) { return toVal } if (!toVal) { return fromVal } return _.uniq(fromVal.concat(toVal)) } } function addExtendedComponentMixin (extendedComponent, newComponent) { if (!(extendedComponent.mixins instanceof Array)) { extendedComponent.mixins = [] } extendedComponent.mixins.push(newComponent) }