diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index dc4a62cc..6256746b 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -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 || diff --git a/lib/src/util/character.dart b/lib/src/util/character.dart index ee51ae94..0c5dea95 100644 --- a/lib/src/util/character.dart +++ b/lib/src/util/character.dart @@ -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; }