File tree 10 files changed +29
-29
lines changed
server-side-rendering/visitors
parser/samples/component-dynamic
dynamic-component-bindings
dynamic-component-update-existing-instance 10 files changed +29
-29
lines changed Original file line number Diff line number Diff line change @@ -205,20 +205,20 @@ export default function visitComponent(
205
205
}
206
206
}
207
207
208
- const isSwitch = node . name === ':Component' ;
208
+ const isDynamicComponent = node . name === ':Component' ;
209
209
210
- const switch_vars = isSwitch && {
210
+ const switch_vars = isDynamicComponent && {
211
211
value : block . getUniqueName ( 'switch_value' ) ,
212
212
props : block . getUniqueName ( 'switch_props' )
213
213
} ;
214
214
215
215
const expression = (
216
216
node . name === ':Self' ? generator . name :
217
- isSwitch ? switch_vars . value :
217
+ isDynamicComponent ? switch_vars . value :
218
218
`%components-${ node . name } `
219
219
) ;
220
220
221
- if ( isSwitch ) {
221
+ if ( isDynamicComponent ) {
222
222
block . contextualise ( node . expression ) ;
223
223
const { dependencies, snippet } = node . metadata ;
224
224
Original file line number Diff line number Diff line change @@ -71,12 +71,12 @@ export default function visitComponent(
71
71
)
72
72
. join ( ', ' ) ;
73
73
74
- const isSwitch = node . name === ':Component' ;
75
- if ( isSwitch ) block . contextualise ( node . expression ) ;
74
+ const isDynamicComponent = node . name === ':Component' ;
75
+ if ( isDynamicComponent ) block . contextualise ( node . expression ) ;
76
76
77
77
const expression = (
78
78
node . name === ':Self' ? generator . name :
79
- isSwitch ? `((${ node . metadata . snippet } ) || __missingComponent)` :
79
+ isDynamicComponent ? `((${ node . metadata . snippet } ) || __missingComponent)` :
80
80
`%components-${ node . name } `
81
81
) ;
82
82
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ import { Node } from '../../interfaces';
15
15
const validTagName = / ^ \! ? [ a - z A - Z ] { 1 , } : ? [ a - z A - Z 0 - 9 \- ] * / ;
16
16
17
17
const SELF = ':Self' ;
18
- const SWITCH = ':Component' ;
18
+ const COMPONENT = ':Component' ;
19
19
20
20
const metaTags = {
21
21
':Window' : true
@@ -166,7 +166,7 @@ export default function tag(parser: Parser) {
166
166
}
167
167
}
168
168
169
- if ( name === SWITCH ) {
169
+ if ( name === COMPONENT ) {
170
170
parser . eat ( '{' , true ) ;
171
171
element . expression = readExpression ( parser ) ;
172
172
parser . allowWhitespace ( ) ;
@@ -248,7 +248,7 @@ function readTagName(parser: Parser) {
248
248
return SELF ;
249
249
}
250
250
251
- if ( parser . eat ( SWITCH ) ) return SWITCH ;
251
+ if ( parser . eat ( COMPONENT ) ) return COMPONENT ;
252
252
253
253
const name = parser . readUntil ( / ( \s | \/ | > ) / ) ;
254
254
Original file line number Diff line number Diff line change 1
- < :Switch {foo ? Foo : Bar} > </ :Switch >
1
+ < :Component {foo ? Foo : Bar} > </ :Component >
Original file line number Diff line number Diff line change 1
1
{
2
- "hash" : 755548012 ,
2
+ "hash" : 410218696 ,
3
3
"html" : {
4
4
"start" : 0 ,
5
- "end" : 37 ,
5
+ "end" : 43 ,
6
6
"type" : " Fragment" ,
7
7
"children" : [
8
8
{
9
9
"start" : 0 ,
10
- "end" : 37 ,
10
+ "end" : 43 ,
11
11
"type" : " Element" ,
12
- "name" : " :Switch " ,
12
+ "name" : " :Component " ,
13
13
"attributes" : [],
14
14
"children" : [],
15
15
"expression" : {
16
16
"type" : " ConditionalExpression" ,
17
- "start" : 10 ,
18
- "end" : 25 ,
17
+ "start" : 13 ,
18
+ "end" : 28 ,
19
19
"test" : {
20
20
"type" : " Identifier" ,
21
- "start" : 10 ,
22
- "end" : 13 ,
21
+ "start" : 13 ,
22
+ "end" : 16 ,
23
23
"name" : " foo"
24
24
},
25
25
"consequent" : {
26
26
"type" : " Identifier" ,
27
- "start" : 16 ,
28
- "end" : 19 ,
27
+ "start" : 19 ,
28
+ "end" : 22 ,
29
29
"name" : " Foo"
30
30
},
31
31
"alternate" : {
32
32
"type" : " Identifier" ,
33
- "start" : 22 ,
34
- "end" : 25 ,
33
+ "start" : 25 ,
34
+ "end" : 28 ,
35
35
"name" : " Bar"
36
36
}
37
37
}
Original file line number Diff line number Diff line change 1
- < :Switch { x ? Foo : Bar } bind:y bind:z />
1
+ < :Component { x ? Foo : Bar } bind:y bind:z />
2
2
3
3
< script >
4
4
import Foo from './Foo.html' ;
Original file line number Diff line number Diff line change 1
- < :Switch { x ? Foo : Bar } on:select ='set({ selected: event.id }) '/>
1
+ < :Component { x ? Foo : Bar } on:select ='set({ selected: event.id }) '/>
2
2
3
3
< script >
4
4
import Foo from './Foo.html' ;
Original file line number Diff line number Diff line change 1
- < :Switch { x ? Foo : Bar } x ='{{x}} '>
1
+ < :Component { x ? Foo : Bar } x ='{{x}} '>
2
2
< p > element</ p >
3
3
4
4
{{tag}}
20
20
< Baz />
21
21
22
22
< div slot ='other '> what goes up must come down</ div >
23
- </ :Switch >
23
+ </ :Component >
24
24
25
25
< script >
26
26
import Foo from './Foo.html' ;
Original file line number Diff line number Diff line change 1
- < :Switch { x ? Foo : Bar } x ='{{x}} '/>
1
+ < :Component { x ? Foo : Bar } x ='{{x}} '/>
2
2
3
3
< script >
4
4
import Foo from './Foo.html' ;
Original file line number Diff line number Diff line change 1
- < :Switch { x ? Foo : Bar } x ='{{x}} '/>
1
+ < :Component { x ? Foo : Bar } x ='{{x}} '/>
2
2
3
3
< script >
4
4
import Foo from './Foo.html' ;
You can’t perform that action at this time.
0 commit comments