inForeignContent method

bool inForeignContent(
  1. Token token,
  2. int type
)

Implementation

bool inForeignContent(Token token, int type) {
  if (tree.openElements.isEmpty) return false;

  final node = tree.openElements.last;
  if (node.namespaceUri == tree.defaultNamespace) return false;

  if (isMathMLTextIntegrationPoint(node)) {
    if (type == TokenKind.startTag &&
        (token as StartTagToken).name != 'mglyph' &&
        token.name != 'malignmark') {
      return false;
    }
    if (type == TokenKind.characters || type == TokenKind.spaceCharacters) {
      return false;
    }
  }

  if (node.localName == 'annotation-xml' &&
      type == TokenKind.startTag &&
      (token as StartTagToken).name == 'svg') {
    return false;
  }

  if (isHTMLIntegrationPoint(node)) {
    if (type == TokenKind.startTag ||
        type == TokenKind.characters ||
        type == TokenKind.spaceCharacters) {
      return false;
    }
  }

  return true;
}