@@ -36,7 +36,7 @@ export function createProxy<T extends typeof VuexModule>( $store :any, cls :T )
3636 // If field is a getter use the normal getter path if not use internal getters.
3737 if ( typeof field === "string" && getterNames . indexOf ( field ) > - 1 ) {
3838 return $store . watch (
39- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + field ] ,
39+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + field ] ,
4040 callback ,
4141 options ,
4242 )
@@ -45,7 +45,7 @@ export function createProxy<T extends typeof VuexModule>( $store :any, cls :T )
4545 const className = cls . name . toLowerCase ( ) ;
4646
4747 return $store . watch (
48- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
48+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
4949 callback ,
5050 options ,
5151 )
@@ -251,13 +251,13 @@ function createLocalWatchers( cls :VuexModuleConstructor, $store :Map, namespace
251251
252252 if ( fieldIsAnExplicitGetter ) {
253253 $store . watch (
254- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + field ] ,
254+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + field ] ,
255255 proxiedWatchFunc ,
256256 )
257257 }
258258 else { // This is so we can also watch implicit getters.
259259 $store . watch (
260- ( ) => ( $store . rootGetters || $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
260+ ( ) => ( namespacedPath ? $store . rootGetters : $store . getters ) [ namespacedPath + `__${ className } _internal_getter__` ] ( field ) ,
261261 proxiedWatchFunc ,
262262 )
263263 }
@@ -311,7 +311,7 @@ function createGettersAndMutationProxyFromState({ cls, proxy, state, $store, nam
311311 get : ( ) => {
312312 // When creating local proxies getters doesn't exist on that context, so we have to account
313313 // for that.
314- const getters = $store . rootGetters || $store . getters ;
314+ const getters = cls . prototype . __namespacedPath__ ? $store . rootGetters : $store . getters ;
315315 if ( getters ) {
316316 const getterPath = refineNamespacedPath ( cls . prototype . __namespacedPath__ ) + `__${ className } _internal_getter__` ;
317317 return getters [ getterPath ] ( path )
@@ -483,9 +483,11 @@ function createGettersAndGetterMutationsProxy({ cls, getters, mutations, proxy,
483483
484484 Object . defineProperty ( proxy , field , {
485485 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 ] ;
489491 }
490492 } )
491493
0 commit comments