@@ -36,7 +36,7 @@ export function createProxy<T extends typeof VuexModule>( $store :any, cls :T )
36
36
// If field is a getter use the normal getter path if not use internal getters.
37
37
if ( typeof field === "string" && getterNames . indexOf ( field ) > - 1 ) {
38
38
return $store . watch (
39
- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + field ] ,
39
+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + field ] ,
40
40
callback ,
41
41
options ,
42
42
)
@@ -45,7 +45,7 @@ export function createProxy<T extends typeof VuexModule>( $store :any, cls :T )
45
45
const className = cls . name . toLowerCase ( ) ;
46
46
47
47
return $store . watch (
48
- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
48
+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
49
49
callback ,
50
50
options ,
51
51
)
@@ -251,13 +251,13 @@ function createLocalWatchers( cls :VuexModuleConstructor, $store :Map, namespace
251
251
252
252
if ( fieldIsAnExplicitGetter ) {
253
253
$store . watch (
254
- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + field ] ,
254
+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + field ] ,
255
255
proxiedWatchFunc ,
256
256
)
257
257
}
258
258
else { // This is so we can also watch implicit getters.
259
259
$store . watch (
260
- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
260
+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
261
261
proxiedWatchFunc ,
262
262
)
263
263
}
@@ -311,7 +311,7 @@ function createGettersAndMutationProxyFromState({ cls, proxy, state, $store, nam
311
311
get : ( ) => {
312
312
// When creating local proxies getters doesn't exist on that context, so we have to account
313
313
// for that.
314
- const getters = $store . rootGetters || $store . getters ;
314
+ const getters = cls . prototype . __namespacedPath__ ? $store . rootGetters : $store . getters ;
315
315
if ( getters ) {
316
316
const getterPath = refineNamespacedPath ( cls . prototype . __namespacedPath__ ) + `__${ className } _internal_getter__` ;
317
317
return getters [ getterPath ] ( path )
@@ -483,9 +483,11 @@ function createGettersAndGetterMutationsProxy({ cls, getters, mutations, proxy,
483
483
484
484
Object . defineProperty ( proxy , field , {
485
485
get : ( ) => {
486
- const storeGetters = $store . rootGetters || $store . getters ;
487
- if ( storeGetters ) return storeGetters [ namespacedPath + field ] ;
488
- else return $store [ namespacedPath + field ] ;
486
+ const storeGetters = namespacedPath ? $store . rootGetters : $store . getters ;
487
+ if ( storeGetters )
488
+ return storeGetters [ namespacedPath + field ] ;
489
+ else
490
+ return $store [ namespacedPath + field ] ;
489
491
}
490
492
} )
491
493
0 commit comments