mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 22:02:00 +01:00
Support !important.
This commit is contained in:
parent
9b05b1c24e
commit
e61862a715
@ -946,11 +946,20 @@ abstract class StylesheetParser extends Parser {
|
||||
break;
|
||||
|
||||
case $exclamation:
|
||||
if (scanner.peekChar(1) != $equal) break loop;
|
||||
scanner.readChar();
|
||||
scanner.readChar();
|
||||
addOperator(BinaryOperator.notEquals);
|
||||
break;
|
||||
var next = scanner.peekChar(1);
|
||||
if (next == $equal) {
|
||||
scanner.readChar();
|
||||
scanner.readChar();
|
||||
addOperator(BinaryOperator.notEquals);
|
||||
break;
|
||||
} else if (next == null ||
|
||||
equalsLetterIgnoreCase($i, next) ||
|
||||
isWhitespace(next)) {
|
||||
addSingleExpression(_importantExpression());
|
||||
break;
|
||||
} else {
|
||||
break loop;
|
||||
}
|
||||
|
||||
case $langle:
|
||||
scanner.readChar();
|
||||
@ -1153,6 +1162,9 @@ abstract class StylesheetParser extends Parser {
|
||||
case $minus:
|
||||
return _minusExpression();
|
||||
|
||||
case $exclamation:
|
||||
return _importantExpression();
|
||||
|
||||
case $0:
|
||||
case $1:
|
||||
case $2:
|
||||
@ -1390,6 +1402,18 @@ abstract class StylesheetParser extends Parser {
|
||||
return _unaryOperation();
|
||||
}
|
||||
|
||||
/// Consumes an `!important` expression.
|
||||
Expression _importantExpression() {
|
||||
assert(scanner.peekChar() == $exclamation);
|
||||
|
||||
var start = scanner.state;
|
||||
scanner.readChar();
|
||||
whitespace();
|
||||
expectIdentifier("important", ignoreCase: true);
|
||||
return new StringExpression(
|
||||
new Interpolation(["!important"], scanner.spanFrom(start)));
|
||||
}
|
||||
|
||||
/// Consumes a unary operation expression.
|
||||
UnaryOperationExpression _unaryOperation() {
|
||||
var start = scanner.state;
|
||||
@ -2167,6 +2191,12 @@ abstract class StylesheetParser extends Parser {
|
||||
var character = scanner.peekChar();
|
||||
if (character == null) return false;
|
||||
if (character == $dot) return scanner.peekChar(1) != $dot;
|
||||
if (character == $exclamation) {
|
||||
var next = scanner.peekChar(1);
|
||||
return next == null ||
|
||||
equalsLetterIgnoreCase($i, next) ||
|
||||
isWhitespace(next);
|
||||
}
|
||||
|
||||
return character == $lparen ||
|
||||
character == $slash ||
|
||||
|
@ -135,5 +135,5 @@ bool characterEqualsIgnoreCase(int character1, int character2) {
|
||||
/// is known to be a lowercase ASCII letter.
|
||||
bool equalsLetterIgnoreCase(int letter, int actual) {
|
||||
assert(letter >= $a && letter <= $z);
|
||||
return (actual & ~_asciiCaseBit) == letter;
|
||||
return (actual | _asciiCaseBit) == letter;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user