Skip to content
This repository was archived by the owner on May 12, 2024. It is now read-only.

Commit 8e775dd

Browse files
committed
fix(firestore): fix plugin for Vue 2
1 parent 3b598ce commit 8e775dd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/vuefire/firestore.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
App,
1212
ComponentPublicInstance,
1313
getCurrentInstance,
14+
isVue3,
1415
onBeforeUnmount,
1516
onUnmounted,
1617
ref,
@@ -171,15 +172,19 @@ export const firestorePlugin = function firestorePlugin(
171172
const globalOptions = Object.assign({}, defaultOptions, pluginOptions)
172173
const { bindName, unbindName } = globalOptions
173174

174-
app.config.globalProperties[unbindName] = function firestoreUnbind(
175+
const GlobalTarget = isVue3
176+
? app.config.globalProperties
177+
: (app as any).prototype
178+
179+
GlobalTarget[unbindName] = function firestoreUnbind(
175180
key: string,
176181
reset?: FirestoreOptions['reset']
177182
) {
178183
internalUnbind(key, firestoreUnbinds.get(this), reset)
179184
delete this.$firestoreRefs[key]
180185
}
181186

182-
app.config.globalProperties[bindName] = function firestoreBind(
187+
GlobalTarget[bindName] = function firestoreBind(
183188
this: ComponentPublicInstance,
184189
key: string,
185190
docOrCollectionRef:

0 commit comments

Comments
 (0)