Skip to content

Commit

Permalink
feat: add fallback for hasInjectionContext (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed May 9, 2023
1 parent 3137c58 commit 610f1e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/v2.7/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ exports.createApp = function (rootComponent, rootProps) {
Object.keys(VueModule).forEach(function (key) {
exports[key] = VueModule[key]
})

// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance()
exports.hasInjectionContext = () => !!VueCompositionAPI.getCurrentInstance()
5 changes: 5 additions & 0 deletions lib/v2.7/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ export var Suspense = /*#__PURE__*/ createMockComponent('Suspense')
export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive')

export * from 'vue'

// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance()
export function hasInjectionContext() {
return !!VueCompositionAPI.getCurrentInstance()
}
3 changes: 3 additions & 0 deletions lib/v2/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ exports.isVue2 = true
exports.isVue3 = false
exports.install = install
exports.version = Vue.version

// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance()
exports.hasInjectionContext = () => !!VueCompositionAPI.getCurrentInstance()
5 changes: 5 additions & 0 deletions lib/v2/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ export var TransitionGroup = /*#__PURE__*/ createMockComponent('TransitionGroup'
export var Teleport = /*#__PURE__*/ createMockComponent('Teleport')
export var Suspense = /*#__PURE__*/ createMockComponent('Suspense')
export var KeepAlive = /*#__PURE__*/ createMockComponent('KeepAlive')

// Not implemented https://github.com/vuejs/core/pull/8111, falls back to getCurrentInstance()
export function hasInjectionContext() {
return !!VueCompositionAPI.getCurrentInstance()
}

0 comments on commit 610f1e1

Please sign in to comment.