@@ -3,39 +3,51 @@ import { lazy } from './lazy'
3
3
4
4
const classAttributeStates : { [ x : string ] : moo . Rules } = {
5
5
doubleClassList : {
6
- lbrace : { match : / (?< ! \\ ) \{ / , push : 'interp ' } ,
6
+ lbrace : { match : / (?< ! \\ ) \{ / , push : 'interpBrace ' } ,
7
7
rbrace : { match : / (?< ! \\ ) \} / , pop : 1 } ,
8
8
end : { match : / (?< ! \\ ) " / , pop : 1 } ,
9
9
classlist : { match : / [ \s \S ] / , lineBreaks : true } ,
10
10
} ,
11
11
singleClassList : {
12
- lbrace : { match : / (?< ! \\ ) \{ / , push : 'interp ' } ,
12
+ lbrace : { match : / (?< ! \\ ) \{ / , push : 'interpBrace ' } ,
13
13
rbrace : { match : / (?< ! \\ ) \} / , pop : 1 } ,
14
14
end : { match : / (?< ! \\ ) ' / , pop : 1 } ,
15
15
classlist : { match : / [ \s \S ] / , lineBreaks : true } ,
16
16
} ,
17
17
tickClassList : {
18
- lbrace : { match : / (?< = (?< ! \\ ) \$ ) \{ / , push : 'interp ' } ,
18
+ lbrace : { match : / (?< = (?< ! \\ ) \$ ) \{ / , push : 'interpBrace ' } ,
19
19
rbrace : { match : / (?< ! \\ ) \} / , pop : 1 } ,
20
20
end : { match : / (?< ! \\ ) ` / , pop : 1 } ,
21
21
classlist : { match : / [ \s \S ] / , lineBreaks : true } ,
22
22
} ,
23
- interp : {
23
+ interpBrace : {
24
24
startSingle : { match : / (?< ! \\ ) ' / , push : 'singleClassList' } ,
25
25
startDouble : { match : / (?< ! \\ ) " / , push : 'doubleClassList' } ,
26
26
startTick : { match : / (?< ! \\ ) ` / , push : 'tickClassList' } ,
27
- lbrace : { match : / (?< ! \\ ) \{ / , push : 'interp ' } ,
27
+ lbrace : { match : / (?< ! \\ ) \{ / , push : 'interpBrace ' } ,
28
28
rbrace : { match : / (?< ! \\ ) \} / , pop : 1 } ,
29
29
text : { match : / [ \s \S ] / , lineBreaks : true } ,
30
30
} ,
31
+ interpSingle : {
32
+ startDouble : { match : / (?< ! \\ ) " / , push : 'doubleClassList' } ,
33
+ startTick : { match : / (?< ! \\ ) ` / , push : 'tickClassList' } ,
34
+ single : { match : / (?< ! \\ ) ' / , pop : 1 } ,
35
+ text : { match : / [ \s \S ] / , lineBreaks : true } ,
36
+ } ,
37
+ interpDouble : {
38
+ startSingle : { match : / (?< ! \\ ) ' / , push : 'singleClassList' } ,
39
+ startTick : { match : / (?< ! \\ ) ` / , push : 'tickClassList' } ,
40
+ double : { match : / (?< ! \\ ) " / , pop : 1 } ,
41
+ text : { match : / [ \s \S ] / , lineBreaks : true } ,
42
+ } ,
31
43
}
32
44
33
45
export const getClassAttributeLexer = lazy ( ( ) =>
34
46
moo . states ( {
35
47
main : {
36
48
start1 : { match : '"' , push : 'doubleClassList' } ,
37
49
start2 : { match : "'" , push : 'singleClassList' } ,
38
- start3 : { match : '{' , push : 'interp ' } ,
50
+ start3 : { match : '{' , push : 'interpBrace ' } ,
39
51
} ,
40
52
...classAttributeStates ,
41
53
} )
@@ -44,10 +56,10 @@ export const getClassAttributeLexer = lazy(() =>
44
56
export const getComputedClassAttributeLexer = lazy ( ( ) =>
45
57
moo . states ( {
46
58
main : {
47
- quote : { match : / [ ' " { ] / , push : 'interp' } ,
59
+ lbrace : { match : '{' , push : 'interpBrace' } ,
60
+ single : { match : "'" , push : 'interpSingle' } ,
61
+ double : { match : '"' , push : 'interpDouble' } ,
48
62
} ,
49
- // TODO: really this should use a different interp definition that is
50
- // terminated correctly based on the initial quote type
51
63
...classAttributeStates ,
52
64
} )
53
65
)
0 commit comments