List? _getAttribute()

in lib/src/encoding_parser.dart [242:321]


  List<String>? _getAttribute() {
    // Step 1 (skip chars)
    var c = _data._skipChars((x) => x == '/' || isWhitespace(x));
    // Step 2
    if (c == '>' || c == null) {
      return null;
    }
    // Step 3
    final attrName = [];
    final attrValue = [];
    // Step 4 attribute name
    while (true) {
      if (c == null) {
        return null;
      } else if (c == '=' && attrName.isNotEmpty) {
        break;
      } else if (isWhitespace(c)) {
        // Step 6!
        c = _data._skipChars();
        c = _data._next();
        break;
      } else if (c == '/' || c == '>') {
        return [attrName.join(), ''];
      } else if (isLetter(c)) {
        attrName.add(c.toLowerCase());
      } else {
        attrName.add(c);
      }
      // Step 5
      c = _data._next();
    }
    // Step 7
    if (c != '=') {
      _data._previous();
      return [attrName.join(), ''];
    }
    // Step 8
    _data._next();
    // Step 9
    c = _data._skipChars();
    // Step 10
    if (c == "'" || c == '"') {
      // 10.1
      final quoteChar = c;
      while (true) {
        // 10.2
        c = _data._next();
        if (c == quoteChar) {
          // 10.3
          _data._next();
          return [attrName.join(), attrValue.join()];
        } else if (isLetter(c)) {
          // 10.4
          attrValue.add(c.toLowerCase());
        } else {
          // 10.5
          attrValue.add(c);
        }
      }
    } else if (c == '>') {
      return [attrName.join(), ''];
    } else if (c == null) {
      return null;
    } else if (isLetter(c)) {
      attrValue.add(c.toLowerCase());
    } else {
      attrValue.add(c);
    }
    // Step 11
    while (true) {
      c = _data._next();
      if (_isSpaceOrAngleBracket(c)) {
        return [attrName.join(), attrValue.join()];
      } else if (isLetter(c)) {
        attrValue.add(c.toLowerCase());
      } else {
        attrValue.add(c);
      }
    }
  }