@@ -21,13 +21,13 @@ module Vue {
21
21
VueExtend ( ) { this = vue ( ) .getAMemberCall ( "extend" ) }
22
22
}
23
23
24
- private newtype TInstance =
24
+ private newtype TComponent =
25
25
MkVueInstance ( DataFlow:: NewNode def ) { def = vue ( ) .getAnInstantiation ( ) } or
26
26
MkExtendedVue ( VueExtend extend ) or
27
27
MkExtendedInstance ( VueExtend extend , DataFlow:: NewNode sub ) {
28
28
sub = extend .getAnInstantiation ( )
29
29
} or
30
- MkComponent ( DataFlow:: CallNode def ) { def = vue ( ) .getAMemberCall ( "component" ) } or
30
+ MkComponentRegistration ( DataFlow:: CallNode def ) { def = vue ( ) .getAMemberCall ( "component" ) } or
31
31
MkSingleFileComponent ( VueFile file )
32
32
33
33
/** Gets the name of a lifecycle hook method. */
@@ -82,22 +82,31 @@ module Vue {
82
82
}
83
83
84
84
/**
85
- * A Vue instance definition.
85
+ * DEPRECATED. This class has been renamed to `Vue::Component`.
86
+ */
87
+ deprecated class Instance = Component ;
88
+
89
+ /**
90
+ * A Vue component, such as a `new Vue({ ... })` call or a `.vue` file.
91
+ *
92
+ * Generally speaking, a component is always created by calling `Vue.extend()` or
93
+ * calling `extend` on another component.
94
+ * Often the `Vue.extend()` call is performed by the Vue
95
+ * framework, however, so the call is not always visible in the user code.
96
+ * For instance, `new Vue(obj)` is shorthand for `new (Vue.extend(obj))`.
86
97
*
87
- * This includes both explicit instantiations of Vue objects, and
88
- * implicit instantiations in the form of components or Vue
89
- * extensions that have not yet been instantiated to a Vue instance.
98
+ * This class covers both the explicit `Vue.extend()` calls an those implicit in the framework.
90
99
*
91
- * The following instances are recognized:
100
+ * The following types of components are recognized:
92
101
* - `new Vue({...})`
93
102
* - `Vue.extend({...})`
94
103
* - `new ExtendedVue({...})`
95
104
* - `Vue.component("my-component", {...})`
96
105
* - single file components in .vue files
97
106
*/
98
- abstract class Instance extends TInstance {
107
+ class Component extends TComponent {
99
108
/** Gets a textual representation of this element. */
100
- abstract string toString ( ) ;
109
+ string toString ( ) { none ( ) } // overridden in subclasses
101
110
102
111
/**
103
112
* Holds if this element is at the specified location.
@@ -120,26 +129,26 @@ module Vue {
120
129
* Gets the options passed to the Vue object, such as the object literal `{...}` in `new Vue{{...})`
121
130
* or the default export of a single-file component.
122
131
*/
123
- abstract DataFlow:: Node getOwnOptionsObject ( ) ;
132
+ DataFlow:: Node getOwnOptionsObject ( ) { none ( ) } // overridden in subclasses
124
133
125
134
/**
126
- * Gets the class component implementing this Vue instance , if any.
135
+ * Gets the class implementing this Vue component , if any.
127
136
*
128
137
* Specifically, this is a class annotated with `@Component` which flows to the options
129
- * object of this Vue instance .
138
+ * object of this Vue component .
130
139
*/
131
140
ClassComponent getAsClassComponent ( ) { result .flowsTo ( getOwnOptionsObject ( ) ) }
132
141
133
142
/**
134
- * Gets the node for option `name` for this instance, this does not include
143
+ * Gets the node for option `name` for this component, not including
135
144
* those from extended objects and mixins.
136
145
*/
137
146
DataFlow:: Node getOwnOption ( string name ) {
138
147
result = getOwnOptionsObject ( ) .getALocalSource ( ) .getAPropertyWrite ( name ) .getRhs ( )
139
148
}
140
149
141
150
/**
142
- * Gets the node for option `name` for this instance , including those from
151
+ * Gets the node for option `name` for this component , including those from
143
152
* extended objects and mixins.
144
153
*/
145
154
DataFlow:: Node getOption ( string name ) {
@@ -164,25 +173,25 @@ module Vue {
164
173
}
165
174
166
175
/**
167
- * Gets a source node flowing into the option `name` of this instance , including those from
176
+ * Gets a source node flowing into the option `name` of this component , including those from
168
177
* extended objects and mixins.
169
178
*/
170
179
pragma [ nomagic]
171
180
DataFlow:: SourceNode getOptionSource ( string name ) { result = getOption ( name ) .getALocalSource ( ) }
172
181
173
182
/**
174
- * Gets the template element used by this instance , if any.
183
+ * Gets the template element used by this component , if any.
175
184
*/
176
- abstract Template:: Element getTemplateElement ( ) ;
185
+ Template:: Element getTemplateElement ( ) { none ( ) } // overridden in subclasses
177
186
178
187
/**
179
- * Gets the node for the `data` option object of this instance .
188
+ * Gets the node for the `data` option object of this component .
180
189
*/
181
190
DataFlow:: Node getData ( ) {
182
191
exists ( DataFlow:: Node data | data = getOption ( "data" ) |
183
192
result = data
184
193
or
185
- // a constructor variant is available for all instance definitions
194
+ // a constructor variant is available for all component definitions
186
195
exists ( DataFlow:: FunctionNode f |
187
196
f .flowsTo ( data ) and
188
197
result = f .getAReturn ( )
@@ -195,13 +204,13 @@ module Vue {
195
204
}
196
205
197
206
/**
198
- * Gets the node for the `template` option of this instance .
207
+ * Gets the node for the `template` option of this component .
199
208
*/
200
209
pragma [ nomagic]
201
210
DataFlow:: SourceNode getTemplate ( ) { result = getOptionSource ( "template" ) }
202
211
203
212
/**
204
- * Gets the node for the `render` option of this instance .
213
+ * Gets the node for the `render` option of this component .
205
214
*/
206
215
pragma [ nomagic]
207
216
DataFlow:: SourceNode getRender ( ) {
@@ -211,19 +220,19 @@ module Vue {
211
220
}
212
221
213
222
/**
214
- * Gets the node for the `methods` option of this instance .
223
+ * Gets the node for the `methods` option of this component .
215
224
*/
216
225
pragma [ nomagic]
217
226
DataFlow:: SourceNode getMethods ( ) { result = getOptionSource ( "methods" ) }
218
227
219
228
/**
220
- * Gets the node for the `computed` option of this instance .
229
+ * Gets the node for the `computed` option of this component .
221
230
*/
222
231
pragma [ nomagic]
223
232
DataFlow:: SourceNode getComputed ( ) { result = getOptionSource ( "computed" ) }
224
233
225
234
/**
226
- * Gets the node for the `watch` option of this instance .
235
+ * Gets the node for the `watch` option of this component .
227
236
*/
228
237
pragma [ nomagic]
229
238
DataFlow:: SourceNode getWatch ( ) { result = getOptionSource ( "watch" ) }
@@ -240,7 +249,7 @@ module Vue {
240
249
}
241
250
242
251
/**
243
- * Gets a node for a member of the `methods` option of this instance .
252
+ * Gets a node for a member of the `methods` option of this component .
244
253
*/
245
254
pragma [ nomagic]
246
255
private DataFlow:: SourceNode getAMethod ( ) {
@@ -251,7 +260,7 @@ module Vue {
251
260
}
252
261
253
262
/**
254
- * Gets a node for a member of the `computed` option of this instance that matches `kind`.
263
+ * Gets a node for a member of the `computed` option of this component that matches `kind`.
255
264
*/
256
265
pragma [ nomagic]
257
266
private DataFlow:: SourceNode getAnAccessor ( DataFlow:: MemberKind kind ) {
@@ -264,7 +273,7 @@ module Vue {
264
273
}
265
274
266
275
/**
267
- * Gets a node for a member `name` of the `computed` option of this instance that matches `kind`.
276
+ * Gets a node for a member `name` of the `computed` option of this component that matches `kind`.
268
277
*/
269
278
private DataFlow:: SourceNode getAccessor ( string name , DataFlow:: MemberKind kind ) {
270
279
result = getComputed ( ) .getAPropertySource ( name ) and kind = DataFlow:: MemberKind:: getter ( )
@@ -276,7 +285,7 @@ module Vue {
276
285
}
277
286
278
287
/**
279
- * Gets the node for the life cycle hook of the `hookName` option of this instance .
288
+ * Gets the node for the life cycle hook of the `hookName` option of this component .
280
289
*/
281
290
pragma [ nomagic]
282
291
DataFlow:: SourceNode getALifecycleHook ( string hookName ) {
@@ -289,7 +298,7 @@ module Vue {
289
298
}
290
299
291
300
/**
292
- * Gets a node for a function that will be invoked with `this` bound to this instance .
301
+ * Gets a node for a function that will be invoked with `this` bound to this component .
293
302
*/
294
303
DataFlow:: FunctionNode getABoundFunction ( ) {
295
304
result = getAMethod ( )
@@ -316,7 +325,7 @@ module Vue {
316
325
}
317
326
318
327
/**
319
- * Gets the data flow node that flows into the property `name` of this instance , or is
328
+ * Gets the data flow node that flows into the property `name` of this component , or is
320
329
* returned form a getter defining that property.
321
330
*/
322
331
DataFlow:: Node getAPropertyValue ( string name ) {
@@ -330,9 +339,9 @@ module Vue {
330
339
}
331
340
332
341
/**
333
- * A Vue instance from `new Vue({...})`.
342
+ * A Vue component from `new Vue({...})`.
334
343
*/
335
- class VueInstance extends Instance , MkVueInstance {
344
+ class VueInstance extends Component , MkVueInstance {
336
345
DataFlow:: NewNode def ;
337
346
338
347
VueInstance ( ) { this = MkVueInstance ( def ) }
@@ -353,7 +362,7 @@ module Vue {
353
362
/**
354
363
* An extended Vue from `Vue.extend({...})`.
355
364
*/
356
- class ExtendedVue extends Instance , MkExtendedVue {
365
+ class ExtendedVue extends Component , MkExtendedVue {
357
366
VueExtend extend ;
358
367
359
368
ExtendedVue ( ) { this = MkExtendedVue ( extend ) }
@@ -374,7 +383,7 @@ module Vue {
374
383
/**
375
384
* An instance of an extended Vue, for example `instance` of `var Ext = Vue.extend({...}); var instance = new Ext({...})`.
376
385
*/
377
- class ExtendedInstance extends Instance , MkExtendedInstance {
386
+ class ExtendedInstance extends Component , MkExtendedInstance {
378
387
VueExtend extend ;
379
388
DataFlow:: NewNode sub ;
380
389
@@ -391,7 +400,7 @@ module Vue {
391
400
override DataFlow:: Node getOwnOptionsObject ( ) { result = sub .getArgument ( 0 ) }
392
401
393
402
override DataFlow:: Node getOption ( string name ) {
394
- result = Instance .super .getOption ( name )
403
+ result = Component .super .getOption ( name )
395
404
or
396
405
result = MkExtendedVue ( extend ) .( ExtendedVue ) .getOption ( name )
397
406
}
@@ -402,10 +411,10 @@ module Vue {
402
411
/**
403
412
* A Vue component from `Vue.component("my-component", { ... })`.
404
413
*/
405
- class Component extends Instance , MkComponent {
414
+ class ComponentRegistration extends Component , MkComponentRegistration {
406
415
DataFlow:: CallNode def ;
407
416
408
- Component ( ) { this = MkComponent ( def ) }
417
+ ComponentRegistration ( ) { this = MkComponentRegistration ( def ) }
409
418
410
419
override string toString ( ) { result = def .toString ( ) }
411
420
@@ -423,7 +432,7 @@ module Vue {
423
432
/**
424
433
* A single file Vue component in a `.vue` file.
425
434
*/
426
- class SingleFileComponent extends Instance , MkSingleFileComponent {
435
+ class SingleFileComponent extends Component , MkSingleFileComponent {
427
436
VueFile file ;
428
437
429
438
SingleFileComponent ( ) { this = MkSingleFileComponent ( file ) }
@@ -496,7 +505,7 @@ module Vue {
496
505
*/
497
506
class InstanceHeapStep extends TaintTracking:: SharedTaintStep {
498
507
override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
499
- exists ( Instance i , string name , DataFlow:: FunctionNode bound |
508
+ exists ( Component i , string name , DataFlow:: FunctionNode bound |
500
509
bound .flowsTo ( i .getABoundFunction ( ) ) and
501
510
not bound .getFunction ( ) instanceof ArrowFunctionExpr and
502
511
succ = bound .getReceiver ( ) .getAPropertyRead ( name ) and
@@ -531,13 +540,13 @@ module Vue {
531
540
*/
532
541
class VHtmlSourceWrite extends TaintTracking:: SharedTaintStep {
533
542
override predicate step ( DataFlow:: Node pred , DataFlow:: Node succ ) {
534
- exists ( Vue:: Instance instance , string expr , VHtmlAttribute attr |
543
+ exists ( Vue:: Component component , string expr , VHtmlAttribute attr |
535
544
attr .getAttr ( ) .getRoot ( ) =
536
- instance .getTemplateElement ( ) .( Vue:: Template:: HtmlElement ) .getElement ( ) and
545
+ component .getTemplateElement ( ) .( Vue:: Template:: HtmlElement ) .getElement ( ) and
537
546
expr = attr .getAttr ( ) .getValue ( ) and
538
547
// only support for simple identifier expressions
539
548
expr .regexpMatch ( "(?i)[a-z0-9_]+" ) and
540
- pred = instance .getAPropertyValue ( expr ) and
549
+ pred = component .getAPropertyValue ( expr ) and
541
550
succ = attr
542
551
)
543
552
}
@@ -638,15 +647,15 @@ module Vue {
638
647
or
639
648
result = routeConfig ( ) .getMember ( "beforeEnter" ) .getParameter ( [ 0 , 1 ] ) .getAnImmediateUse ( )
640
649
or
641
- exists ( Instance i |
642
- result = i .getABoundFunction ( ) .getAFunctionValue ( ) .getReceiver ( ) .getAPropertyRead ( "$route" )
650
+ exists ( Component c |
651
+ result = c .getABoundFunction ( ) .getAFunctionValue ( ) .getReceiver ( ) .getAPropertyRead ( "$route" )
643
652
or
644
653
result =
645
- i .getALifecycleHook ( [ "beforeRouteEnter" , "beforeRouteUpdate" , "beforeRouteLeave" ] )
654
+ c .getALifecycleHook ( [ "beforeRouteEnter" , "beforeRouteUpdate" , "beforeRouteLeave" ] )
646
655
.getAFunctionValue ( )
647
656
.getParameter ( [ 0 , 1 ] )
648
657
or
649
- result = i .getWatchHandler ( "$route" ) .getParameter ( [ 0 , 1 ] )
658
+ result = c .getWatchHandler ( "$route" ) .getParameter ( [ 0 , 1 ] )
650
659
)
651
660
)
652
661
or
@@ -664,7 +673,7 @@ module Vue {
664
673
this = routeObject ( ) .getAPropertyRead ( name )
665
674
or
666
675
exists ( string prop |
667
- this = any ( Instance i ) .getWatchHandler ( prop ) .getParameter ( [ 0 , 1 ] ) and
676
+ this = any ( Component c ) .getWatchHandler ( prop ) .getParameter ( [ 0 , 1 ] ) and
668
677
name = prop .regexpCapture ( "\\$route\\.(params|query|hash|path|fullPath)\\b.*" , 1 )
669
678
)
670
679
|
0 commit comments