File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 6
6
7
7
const utils = require ( '../utils' )
8
8
9
+ function getComputedProperties ( componentProperties ) {
10
+ const computedPropertiesNode = componentProperties
11
+ . filter ( p =>
12
+ p . key . type === 'Identifier' &&
13
+ p . key . name === 'computed' &&
14
+ p . value . type === 'ObjectExpression'
15
+ ) [ 0 ]
16
+
17
+ if ( ! computedPropertiesNode ) { return [ ] }
18
+
19
+ const computedProperties = computedPropertiesNode . value . properties
20
+
21
+ return computedProperties . map ( cp => {
22
+ const key = cp . key . name
23
+ let value
24
+
25
+ if ( cp . value . type === 'FunctionExpression' ) {
26
+ value = cp . value . body . body
27
+ } else if ( cp . value . type === 'ObjectExpression' ) {
28
+ value = cp . value . properties
29
+ . filter ( p =>
30
+ p . key . type === 'Identifier' &&
31
+ p . key . name === 'get' &&
32
+ p . value . type === 'FunctionExpression'
33
+ )
34
+ . map ( p => p . value . body . body ) [ 0 ]
35
+ }
36
+
37
+ return { key, value }
38
+ } )
39
+ }
40
+
9
41
function create ( context ) {
10
42
return utils . executeOnVueComponent ( context , ( properties ) => {
43
+ const computedProperties = getComputedProperties ( properties )
44
+ // to be continued...
11
45
} )
12
46
}
13
47
You can’t perform that action at this time.
0 commit comments