@@ -167,33 +167,55 @@ describe('component: proxy', () => {
167
167
data ( ) {
168
168
return {
169
169
foo : 0 ,
170
+ $foo : 0 ,
170
171
}
171
172
} ,
173
+ computed : {
174
+ cmp : ( ) => {
175
+ throw new Error ( 'value of cmp should not be accessed' )
176
+ } ,
177
+ $cmp : ( ) => {
178
+ throw new Error ( 'value of $cmp should not be read' )
179
+ } ,
180
+ } ,
172
181
setup ( ) {
173
182
return {
174
183
bar : 1 ,
175
184
}
176
185
} ,
186
+ __cssModules : {
187
+ $style : { } ,
188
+ cssStyles : { } ,
189
+ } ,
177
190
mounted ( ) {
178
191
instanceProxy = this
179
192
} ,
180
193
}
181
194
182
195
const app = createApp ( Comp , { msg : 'hello' } )
183
196
app . config . globalProperties . global = 1
197
+ app . config . globalProperties . $global = 1
184
198
185
199
app . mount ( nodeOps . createElement ( 'div' ) )
186
200
187
201
// props
188
202
expect ( 'msg' in instanceProxy ) . toBe ( true )
189
203
// data
190
204
expect ( 'foo' in instanceProxy ) . toBe ( true )
191
- // ctx
205
+ expect ( '$foo' in instanceProxy ) . toBe ( false )
206
+ // setupState
192
207
expect ( 'bar' in instanceProxy ) . toBe ( true )
208
+ // ctx
209
+ expect ( 'cmp' in instanceProxy ) . toBe ( true )
210
+ expect ( '$cmp' in instanceProxy ) . toBe ( true )
193
211
// public properties
194
212
expect ( '$el' in instanceProxy ) . toBe ( true )
213
+ // CSS modules
214
+ expect ( '$style' in instanceProxy ) . toBe ( true )
215
+ expect ( 'cssStyles' in instanceProxy ) . toBe ( true )
195
216
// global properties
196
217
expect ( 'global' in instanceProxy ) . toBe ( true )
218
+ expect ( '$global' in instanceProxy ) . toBe ( true )
197
219
198
220
// non-existent
199
221
expect ( '$foobar' in instanceProxy ) . toBe ( false )
@@ -202,19 +224,26 @@ describe('component: proxy', () => {
202
224
// #4962 triggering getter should not cause non-existent property to
203
225
// pass the has check
204
226
instanceProxy . baz
227
+ instanceProxy . $baz
205
228
expect ( 'baz' in instanceProxy ) . toBe ( false )
229
+ expect ( '$baz' in instanceProxy ) . toBe ( false )
206
230
207
231
// set non-existent (goes into proxyTarget sink)
208
232
instanceProxy . baz = 1
209
233
expect ( 'baz' in instanceProxy ) . toBe ( true )
234
+ instanceProxy . $baz = 1
235
+ expect ( '$baz' in instanceProxy ) . toBe ( true )
210
236
211
237
// dev mode ownKeys check for console inspection
212
238
// should only expose own keys
213
239
expect ( Object . keys ( instanceProxy ) ) . toMatchObject ( [
214
240
'msg' ,
215
241
'bar' ,
216
242
'foo' ,
243
+ 'cmp' ,
244
+ '$cmp' ,
217
245
'baz' ,
246
+ '$baz' ,
218
247
] )
219
248
} )
220
249
0 commit comments