From 253ae198a39cdbe45cb0045a78d965cd1e91ddec Mon Sep 17 00:00:00 2001 From: cccblade <156088158+cccblade@users.noreply.github.com> Date: Thu, 1 Feb 2024 19:29:59 +0800 Subject: [PATCH] fix: replace arrow functions for compatibility (#251) --- lib/index.iife.js | 8 ++++++-- lib/v2.7/index.cjs | 4 +++- lib/v2/index.cjs | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/index.iife.js b/lib/index.iife.js index 2179268..085d02c 100644 --- a/lib/index.iife.js +++ b/lib/index.iife.js @@ -19,7 +19,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) { VueDemi.Vue2 = Vue VueDemi.version = Vue.version VueDemi.warn = Vue.util.warn - VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance() + VueDemi.hasInjectionContext = function() { + return !!VueDemi.getCurrentInstance() + } function createApp(rootComponent, rootProps) { var vm var provide = {} @@ -72,7 +74,9 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) { VueDemi.Vue = Vue VueDemi.Vue2 = Vue VueDemi.version = Vue.version - VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance() + VueDemi.hasInjectionContext = function() { + return !!VueDemi.getCurrentInstance() + } } else { console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.') } diff --git a/lib/v2.7/index.cjs b/lib/v2.7/index.cjs index 1dce010..8fa3b68 100644 --- a/lib/v2.7/index.cjs +++ b/lib/v2.7/index.cjs @@ -55,4 +55,6 @@ Object.keys(VueModule).forEach(function (key) { }) // Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() -exports.hasInjectionContext = () => !!VueModule.getCurrentInstance() +exports.hasInjectionContext = function() { + return !!VueModule.getCurrentInstance() +} \ No newline at end of file diff --git a/lib/v2/index.cjs b/lib/v2/index.cjs index 5f873d2..c3d298e 100644 --- a/lib/v2/index.cjs +++ b/lib/v2/index.cjs @@ -29,4 +29,6 @@ exports.install = install exports.version = Vue.version // Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance() -exports.hasInjectionContext = () => !!VueCompositionAPI.getCurrentInstance() +exports.hasInjectionContext = function () { + return !!VueCompositionAPI.getCurrentInstance() +}