File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -1795,7 +1795,6 @@ export class ListEntry extends Node {
1795
1795
1796
1796
export class LessGuard extends Node {
1797
1797
1798
- public isNegated ?: boolean ;
1799
1798
private conditions ?: Nodelist ;
1800
1799
1801
1800
public getConditions ( ) : Nodelist {
@@ -1808,6 +1807,7 @@ export class LessGuard extends Node {
1808
1807
1809
1808
export class GuardCondition extends Node {
1810
1809
1810
+ public isNegated ?: boolean ;
1811
1811
public variable ?: Node ;
1812
1812
public isEquals ?: boolean ;
1813
1813
public isGreater ?: boolean ;
Original file line number Diff line number Diff line change @@ -730,7 +730,6 @@ export class LESSParser extends cssParser.Parser {
730
730
}
731
731
const node = < nodes . LessGuard > this . create ( nodes . LessGuard ) ;
732
732
this . consumeToken ( ) ; // when
733
- node . isNegated = this . acceptIdent ( 'not' ) ;
734
733
735
734
if ( ! node . getConditions ( ) . addChild ( this . _parseGuardCondition ( ) ) ) {
736
735
return < nodes . LessGuard > this . finish ( node , ParseError . ConditionExpected ) ;
@@ -745,12 +744,14 @@ export class LESSParser extends cssParser.Parser {
745
744
}
746
745
747
746
public _parseGuardCondition ( ) : nodes . Node | null {
748
-
749
- if ( ! this . peek ( TokenType . ParenthesisL ) ) {
747
+ const node = this . create ( nodes . GuardCondition ) ;
748
+ node . isNegated = this . acceptIdent ( 'not' ) ;
749
+ if ( ! this . accept ( TokenType . ParenthesisL ) ) {
750
+ if ( node . isNegated ) {
751
+ return this . finish ( node , ParseError . LeftParenthesisExpected ) ;
752
+ }
750
753
return null ;
751
754
}
752
- const node = this . create ( nodes . GuardCondition ) ;
753
- this . consumeToken ( ) ; // ParenthesisL
754
755
755
756
if ( ! node . addChild ( this . _parseExpr ( ) ) ) {
756
757
// empty (?)
Original file line number Diff line number Diff line change @@ -313,6 +313,7 @@ suite('LESS - Parser', () => {
313
313
314
314
test ( 'CSS Guards' , function ( ) {
315
315
const parser = new LESSParser ( ) ;
316
+ assertNode ( '.selector when not ( @testCondition = 2) and not ( @testCondition = 3 ) { }' , parser , parser . _parseStylesheet . bind ( parser ) ) ;
316
317
assertNode ( 'button when (@my-option = true) { color: white; }' , parser , parser . _parseStylesheet . bind ( parser ) ) ;
317
318
assertNode ( '.something .other when (@my-option = true) { color: white; }' , parser , parser . _parseStylesheet . bind ( parser ) ) ;
318
319
assertNode ( '& when (@my-option = true) { button { color: white; } }' , parser , parser . _parseStylesheet . bind ( parser ) ) ;
You can’t perform that action at this time.
0 commit comments