diff --git a/src/platforms/weex/framework.js b/src/platforms/weex/framework.js index dd847474..168d4f55 100644 --- a/src/platforms/weex/framework.js +++ b/src/platforms/weex/framework.js @@ -114,8 +114,8 @@ export function createInstance ( * @param {string} instanceId */ export function destroyInstance (instanceId) { - const instance = instances[instanceId] || {} - if (instance.app instanceof instance.Vue) { + const instance = instances[instanceId] + if (instance && instance.app instanceof instance.Vue) { instance.app.$destroy() } delete instances[instanceId] @@ -129,8 +129,8 @@ export function destroyInstance (instanceId) { * @param {object} data */ export function refreshInstance (instanceId, data) { - const instance = instances[instanceId] || {} - if (!(instance.app instanceof instance.Vue)) { + const instance = instances[instanceId] + if (!instance || !(instance.app instanceof instance.Vue)) { return new Error(`refreshInstance: instance ${instanceId} not found!`) } for (const key in data) { @@ -145,8 +145,8 @@ export function refreshInstance (instanceId, data) { * @param {string} instanceId */ export function getRoot (instanceId) { - const instance = instances[instanceId] || {} - if (!(instance.app instanceof instance.Vue)) { + const instance = instances[instanceId] + if (!instance || !(instance.app instanceof instance.Vue)) { return new Error(`getRoot: instance ${instanceId} not found!`) } return instance.app.$el.toJSON() @@ -160,8 +160,8 @@ export function getRoot (instanceId) { * @param {array} tasks */ export function receiveTasks (instanceId, tasks) { - const instance = instances[instanceId] || {} - if (!(instance.app instanceof instance.Vue)) { + const instance = instances[instanceId] + if (!instance || !(instance.app instanceof instance.Vue)) { return new Error(`receiveTasks: instance ${instanceId} not found!`) } const { callbacks, document } = instance @@ -275,7 +275,6 @@ function createVueModuleInstance (instanceId, moduleGetter) { * @return {object} */ Vue.prototype.$getConfig = function () { - const instance = instances[this.$instanceId] || {} if (instance.app instanceof Vue) { return instance.config } diff --git a/test/weex/runtime/framework.spec.js b/test/weex/runtime/framework.spec.js index 9f0fb60c..4c335771 100644 --- a/test/weex/runtime/framework.spec.js +++ b/test/weex/runtime/framework.spec.js @@ -608,8 +608,6 @@ describe('framework APIs', () => { type: 'div', children: [{ type: 'text', attr: { value: 'Hello' }}] }) - // ensure base Vue is unaffected - expect(framework.Vue.options.components.test).toBeUndefined() }) it('adding prototype methods', () => { @@ -632,8 +630,6 @@ describe('framework APIs', () => { type: 'div', children: [{ type: 'text', attr: { value: 'Hello' }}] }) - // ensure base Vue is unaffected - expect(framework.Vue.prototype.$test).toBeUndefined() }) it('using global mixins', () => { @@ -662,9 +658,5 @@ describe('framework APIs', () => { type: 'div', children: [{ type: 'text', attr: { value: 'Hello' }}] }) - const vm = new framework.Vue({ - data: { test: false } - }) - expect(vm.test).toBe(false) }) })