processStartTag method

  1. @override
Token? processStartTag(
  1. StartTagToken token
)
override

Implementation

@override
Token? processStartTag(StartTagToken token) {
  final currentNode = tree.openElements.last;
  if (breakoutElements.contains(token.name) ||
      (token.name == 'font' &&
          (token.data.containsKey('color') ||
              token.data.containsKey('face') ||
              token.data.containsKey('size')))) {
    parser.parseError(token.span,
        'unexpected-html-element-in-foreign-content', {'name': token.name});
    while (tree.openElements.last.namespaceUri != tree.defaultNamespace &&
        !parser.isHTMLIntegrationPoint(tree.openElements.last) &&
        !parser.isMathMLTextIntegrationPoint(tree.openElements.last)) {
      tree.openElements.removeLast();
    }
    return token;
  } else {
    if (currentNode.namespaceUri == Namespaces.mathml) {
      parser.adjustMathMLAttributes(token);
    } else if (currentNode.namespaceUri == Namespaces.svg) {
      adjustSVGTagNames(token);
      parser.adjustSVGAttributes(token);
    }
    parser.adjustForeignAttributes(token);
    token.namespace = currentNode.namespaceUri;
    tree.insertElement(token);
    if (token.selfClosing) {
      tree.openElements.removeLast();
      token.selfClosingAcknowledged = true;
    }
    return null;
  }
}