simpleSelectorTail method

SimpleSelector? simpleSelectorTail()

type_selector | universal | HASH | class | attrib | pseudo

Implementation

SimpleSelector? simpleSelectorTail() {
  // Check for HASH | class | attrib | pseudo | negation
  var start = _peekToken.span;
  switch (_peek()) {
    case TokenKind.HASH:
      _eat(TokenKind.HASH);

      if (_anyWhiteSpaceBeforePeekToken(TokenKind.HASH)) {
        _error('Not a valid ID selector expected #id', location: _makeSpan(start));
        return null;
      }
      return IdSelector(identifier());
    case TokenKind.DOT:
      _eat(TokenKind.DOT);

      if (_anyWhiteSpaceBeforePeekToken(TokenKind.DOT)) {
        _error('Not a valid class selector expected .className', location: _makeSpan(start));
        return null;
      }
      return ClassSelector(identifier());
    case TokenKind.COLON:
      // :pseudo-class ::pseudo-element
      return processPseudoSelector(start);
    case TokenKind.LBRACK:
      return processAttribute();
    case TokenKind.DOUBLE:
      _error('name must start with a alpha character, but found a number');
      _next();
      break;
  }
  return null;
}