1
1
import Vue from 'vue' ;
2
2
import Vuex from 'vuex' ;
3
- import { mapGetters , mapState , mapMutations , mapActions } from 'vuex' ;
3
+ import { mapGetters , mapState , mapMutations , mapActions , createNamespacedHelpers } from 'vuex' ;
4
4
5
5
Vue . use ( Vuex ) ;
6
6
@@ -18,6 +18,9 @@ const submoduleB = {
18
18
}
19
19
} ;
20
20
21
+ const { mapGetters : mapGettersA } = createNamespacedHelpers ( 'submoduleA' ) ;
22
+ const { mapGetters : mapGettersB } = createNamespacedHelpers ( 'submoduleB' ) ;
23
+
21
24
const store = new Vuex . Store ( {
22
25
getters : {
23
26
getterWithSink : state => { sink ( state . tainted ) ; } , // NOT OK
@@ -72,8 +75,10 @@ const Component = new Vue({
72
75
derivedUntainted : state => state . untainted ,
73
76
} ) ,
74
77
...mapState ( [ 'tainted2' ] ) ,
75
- ...mapGetters ( 'submoduleA' , { fooA : 'foo' } ) ,
76
- ...mapGetters ( 'submoduleB' , { fooB : 'foo' } ) ,
78
+ ...mapGetters ( 'submoduleA' , { fooA1 : 'foo' } ) ,
79
+ ...mapGettersA ( { fooA2 : 'foo' } ) ,
80
+ ...mapGetters ( 'submoduleB' , { fooB1 : 'foo' } ) ,
81
+ ...mapGettersB ( { fooB2 : 'foo' } ) ,
77
82
} ,
78
83
methods : {
79
84
doCommitsAndActions ( ) {
@@ -95,8 +100,10 @@ const Component = new Vue({
95
100
sink ( this . untaintedGetter ) ; // OK
96
101
sink ( this . derivedUntainted ) ; // OK
97
102
98
- sink ( this . fooA ) ; // NOT OK
99
- sink ( this . fooB ) ; // OK
103
+ sink ( this . fooA1 ) ; // NOT OK
104
+ sink ( this . fooA2 ) ; // NOT OK
105
+ sink ( this . fooB1 ) ; // OK
106
+ sink ( this . fooB2 ) ; // OK
100
107
} ,
101
108
...mapMutations ( { sneakyTaint3 : 'setTainted3' } ) ,
102
109
...mapActions ( { emitTaint4 : 'doTaint4' } ) ,
0 commit comments