processDeclaration method

void processDeclaration(
  1. CSSStyleDeclaration style
)

Implementation

void processDeclaration(CSSStyleDeclaration style) {
  // IDENT ':' expr '!important'?
  if (TokenKind.isIdentifier(_peekToken.kind)) {
    var propertyIdent = camelize(identifier().name);

    var resetProperty = false;
    var keepGoing = true;
    while (keepGoing) {
      switch (_peek()) {
        case TokenKind.COLON:
          _eat(TokenKind.COLON);
          keepGoing = false;
          break;
        case TokenKind.SEMICOLON:
        case TokenKind.NEWLINE:
          resetProperty = true;
          _next();
          break;
        case TokenKind.IDENTIFIER:
          if (resetProperty) {
            propertyIdent = identifier().name;
          }
          break;
        default:
          keepGoing = false;
      }
    }

    var expr = processExpr();
    if (expr != null) {
      // Handle !important (prio)
      var importantPriority = false;
      // handle multi-important
      while (_maybeEat(TokenKind.IMPORTANT)) {
        importantPriority = true;
      }
      style.setProperty(propertyIdent, expr, isImportant: importantPriority, baseHref: href);
    }
  } else if (_peekToken.kind == TokenKind.VAR_DEFINITION) {
    _next();
  } else if (_peekToken.kind == TokenKind.DIRECTIVE_INCLUDE) {
    // TODO @include mixinName in the declaration area.
  } else if (_peekToken.kind == TokenKind.DIRECTIVE_EXTEND) {
    _next();
  }
}