File tree 4 files changed +14
-92
lines changed
4 files changed +14
-92
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.15.0
2
+ * reversed parsing of semicolon after mixin without body fix
3
+
1
4
## 0.14.0
2
5
* fixed parsing of semicolon after mixin without body
3
6
Original file line number Diff line number Diff line change @@ -225,57 +225,5 @@ export default class LessParser extends Parser {
225
225
this . unknownWord ( start ) ;
226
226
}
227
227
228
- /* eslint-enable max-statements */
229
-
230
- loop ( ) {
231
- while ( this . pos < this . tokens . length ) {
232
- const token = this . tokens [ this . pos ] ;
233
-
234
- switch ( token [ 0 ] ) {
235
- case 'word' :
236
- case ':' :
237
- this . word ( ) ;
238
- break ;
239
-
240
- case '}' :
241
- this . end ( token ) ;
242
- break ;
243
-
244
- case 'comment' :
245
- this . comment ( token ) ;
246
- break ;
247
-
248
- case 'at-word' :
249
- this . atrule ( token ) ;
250
- break ;
251
-
252
- case '{' :
253
- this . emptyRule ( token ) ;
254
- break ;
255
-
256
- case ';' :
257
- {
258
- const lastNode = this . current && this . current . last ;
259
-
260
- // mark semicolon, but don't save it
261
- if ( lastNode && lastNode . ruleWithoutBody ) {
262
- lastNode . raws . semicolon = true ;
263
- } else {
264
- this . spaces += token [ 1 ] ;
265
- }
266
-
267
- break ;
268
- }
269
- default :
270
- this . spaces += token [ 1 ] ;
271
- break ;
272
- }
273
-
274
- this . pos += 1 ;
275
- }
276
-
277
- this . endFile ( ) ;
278
- }
279
-
280
- /* eslint-enable complexity */
281
- }
228
+ /* eslint-enable max-statements, complexity */
229
+ }
Original file line number Diff line number Diff line change @@ -19,29 +19,16 @@ describe('#postcss', () => {
19
19
done ( ) ;
20
20
} ) . catch ( done ) ;
21
21
} ) ;
22
+
23
+ it ( 'can parse LESS mixins as at rules' , ( done ) => {
24
+ const lessText = '.foo (@bar; @baz...) { border: @{baz}; }' ;
22
25
23
- it ( 'can parse LESS mixins without body' , ( done ) => {
24
- const lessText = `.test4 {
25
- .mixin();
26
- background: red;
27
- }` ;
28
-
29
26
postcss ( )
30
27
. process ( lessText , { syntax : lessSyntax } )
31
28
. then ( ( result ) => {
32
- const [ rule , declaration ] = result . root . first . nodes ;
33
-
34
- expect ( rule . raws ) . to . deep . equal ( {
35
- before : '\n ' ,
36
- between : '' ,
37
- after : '' ,
38
- semicolon : true
39
- } ) ;
40
-
41
- expect ( declaration . raws ) . to . deep . equal ( {
42
- before : '\n ' ,
43
- between : ': '
44
- } ) ;
29
+ expect ( result ) . to . be . not . null ;
30
+ expect ( result . css ) . to . equal ( lessText ) ;
31
+ expect ( result . content ) . to . equal ( lessText ) ;
45
32
46
33
done ( ) ;
47
34
} ) . catch ( done ) ;
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ describe('#stringify()', () => {
60
60
syntax : postcssLess ,
61
61
stringifier : stringify
62
62
} ) . then ( ( result ) => {
63
- expect ( result . content ) . to . eql ( '.selector:extend(.f, .g) {&:extend(.a)}' ) ;
63
+ expect ( result . content ) . to . eql ( less ) ;
64
64
done ( ) ;
65
65
} ) . catch ( ( error ) => {
66
66
done ( error ) ;
@@ -103,33 +103,17 @@ describe('#stringify()', () => {
103
103
width: @width;
104
104
}
105
105
}
106
-
106
+
107
107
.rotation(@deg:5deg){
108
108
.transform(rotate(@deg));
109
109
}
110
110
` ;
111
-
112
- function prepareOutput ( str ) {
113
- return str . replace ( / \s { 2 , } / g, ' ' ) ;
114
- }
115
111
116
112
postcss ( ) . process ( less , {
117
113
syntax : postcssLess ,
118
114
stringifier : stringify
119
115
} ) . then ( ( result ) => {
120
- expect ( prepareOutput ( result . content ) ) . to . eql ( prepareOutput ( `
121
- .container {
122
- .mixin-1()
123
- .mixin-2
124
- .mixin-3 (@width: 100px) {
125
- width: @width;
126
- }
127
- }
128
-
129
- .rotation(@deg:5deg){
130
- .transform(rotate(@deg))
131
- }
132
- ` ) ) ;
116
+ expect ( result . content ) . to . eql ( less ) ;
133
117
done ( ) ;
134
118
} ) . catch ( ( error ) => {
135
119
done ( error ) ;
You can’t perform that action at this time.
0 commit comments