File tree Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Expand file tree Collapse file tree 4 files changed +48
-7
lines changed Original file line number Diff line number Diff line change @@ -1140,16 +1140,15 @@ less.Parser = function Parser(env) {
1140
1140
1141
1141
if ( ! $ ( '[' ) ) return ;
1142
1142
1143
- if ( key = $ ( / ^ (?: [ _ A - Z a - z 0 - 9 - ] | \\ .) + / ) || $ ( this . entities . quoted ) ) {
1144
- if ( ( op = $ ( / ^ [ | ~ * $ ^ ] ? = / ) ) &&
1145
- ( val = $ ( this . entities . quoted ) || $ ( / ^ [ \w - ] + / ) ) ) {
1146
- attr = [ key , op , val . toCSS ? val . toCSS ( ) : val ] . join ( '' ) ;
1147
- } else { attr = key }
1143
+ key = expect ( / ^ (?: [ _ A - Z a - z 0 - 9 -\* ] * \| ) ? (?: [ _ A - Z a - z 0 - 9 - ] | \\ .) + / ) ;
1144
+
1145
+ if ( ( op = $ ( / ^ [ | ~ * $ ^ ] ? = / ) ) ) {
1146
+ val = $ ( this . entities . quoted ) || $ ( / ^ [ \w - ] + / ) ;
1148
1147
}
1149
1148
1150
- if ( ! $ ( ']' ) ) return ;
1149
+ expect ( ']' ) ;
1151
1150
1152
- if ( attr ) { return "[" + attr + "]" }
1151
+ return new ( tree . Attribute ) ( key , op , val ) ;
1153
1152
} ,
1154
1153
1155
1154
//
Original file line number Diff line number Diff line change @@ -34,6 +34,32 @@ tree.Element.prototype = {
34
34
}
35
35
} ;
36
36
37
+ tree . Attribute = function ( key , op , value ) {
38
+ this . key = key ;
39
+ this . op = op ;
40
+ this . value = value ;
41
+ } ;
42
+ tree . Attribute . prototype = {
43
+ type : "Attribute" ,
44
+ accept : function ( visitor ) {
45
+ this . value = visitor . visit ( this . value ) ;
46
+ } ,
47
+ eval : function ( env ) {
48
+ return new ( tree . Attribute ) ( this . key ,
49
+ this . op , ( this . value && this . value . eval ) ? this . value . eval ( env ) : this . value ) ;
50
+ } ,
51
+ toCSS : function ( env ) {
52
+ var value = this . key ;
53
+
54
+ if ( this . op ) {
55
+ value += this . op ;
56
+ value += ( this . value . toCSS ? this . value . toCSS ( env ) : this . value ) ;
57
+ }
58
+
59
+ return '[' + value + ']' ;
60
+ }
61
+ } ;
62
+
37
63
tree . Combinator = function ( value ) {
38
64
if ( value === ' ' ) {
39
65
this . value = ' ' ;
Original file line number Diff line number Diff line change @@ -128,3 +128,11 @@ p a span {
128
128
.test : nth-child (odd): not (: nth-child (3 )) {
129
129
color : # ff0000 ;
130
130
}
131
+ [prop ],
132
+ [prop = "value3" ],
133
+ [prop *= "val3" ],
134
+ [ |prop ~= "val3" ],
135
+ [* |prop $= "val3" ],
136
+ [ns |prop ^= "val3" ] {
137
+ attributes : yes;
138
+ }
Original file line number Diff line number Diff line change 129
129
& :nth- child(odd):not (:nth- child(3 )) {
130
130
color : #ff0000 ;
131
131
}
132
+ }
133
+ [prop],
134
+ [prop= " value@{num} " ],
135
+ [prop*= " val@{num} " ],
136
+ [|prop~= " val@{num} " ],
137
+ [* |prop$= " val@{num} " ],
138
+ [ns|prop^= " val@{num} " ] {
139
+ attributes: yes;
132
140
}
You can’t perform that action at this time.
0 commit comments