startTagListItem method

void startTagListItem(
  1. StartTagToken token
)

Implementation

void startTagListItem(StartTagToken token) {
  parser.framesetOK = false;

  final stopNamesMap = const {
    'li': ['li'],
    'dt': ['dt', 'dd'],
    'dd': ['dt', 'dd']
  };
  final stopNames = stopNamesMap[token.name!]!;
  for (var node in tree.openElements.reversed) {
    if (stopNames.contains(node.localName)) {
      parser.phase.processEndTag(EndTagToken(node.localName));
      break;
    }
    if (specialElements.contains(getElementNameTuple(node)) &&
        !const ['address', 'div', 'p'].contains(node.localName)) {
      break;
    }
  }

  if (tree.elementInScope('p', variant: 'button')) {
    parser.phase.processEndTag(EndTagToken('p'));
  }

  tree.insertElement(token);
}