File tree 3 files changed +39
-0
lines changed
test/generator/samples/attribute-prefer-expression
3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { parseExpressionAt } from 'acorn' ;
2
2
3
+ const literals = new Map ( [
4
+ [ 'true' , true ] ,
5
+ [ 'false' , false ] ,
6
+ [ 'null' , null ]
7
+ ] ) ;
8
+
3
9
export default function readExpression ( parser ) {
4
10
const start = parser . index ;
5
11
6
12
const name = parser . readUntil ( / \s * } } / ) ;
7
13
if ( name && / ^ [ a - z ] + $ / . test ( name ) ) {
14
+ const end = start + name . length ;
15
+
16
+ if ( literals . has ( name ) ) {
17
+ return {
18
+ type : 'Literal' ,
19
+ start,
20
+ end,
21
+ value : literals . get ( name ) ,
22
+ raw : name
23
+ } ;
24
+ }
25
+
8
26
return {
9
27
type : 'Identifier' ,
10
28
start,
Original file line number Diff line number Diff line change
1
+ export default {
2
+ 'skip-ssr' : true ,
3
+
4
+ data : {
5
+ foo : false
6
+ } ,
7
+
8
+ test ( assert , component , target ) {
9
+ const inputs = target . querySelectorAll ( 'input' ) ;
10
+
11
+ assert . ok ( inputs [ 0 ] . checked ) ;
12
+ assert . ok ( ! inputs [ 1 ] . checked ) ;
13
+
14
+ component . set ( { foo : true } ) ;
15
+
16
+ assert . ok ( ! inputs [ 0 ] . checked ) ;
17
+ assert . ok ( inputs [ 1 ] . checked ) ;
18
+ }
19
+ } ;
Original file line number Diff line number Diff line change
1
+ < input type ='radio ' bind:group ='foo ' value ='{{false}} '>
2
+ < input type ='radio ' bind:group ='foo ' value ='{{true}} '>
You can’t perform that action at this time.
0 commit comments