resetInsertionMode method

void resetInsertionMode()

Implementation

void resetInsertionMode() {
  // The name of this method is mostly historical. (It's also used in the
  // specification.)
  for (var node in tree.openElements.reversed) {
    var nodeName = node.localName;
    final last = node == tree.openElements[0];
    if (last) {
      assert(innerHTMLMode);
      nodeName = innerHTML;
    }
    // Check for conditions that should only happen in the innerHTML
    // case
    switch (nodeName) {
      case 'select':
      case 'colgroup':
      case 'head':
      case 'html':
        assert(innerHTMLMode);
        break;
    }
    if (!last && node.namespaceUri != tree.defaultNamespace) {
      continue;
    }
    switch (nodeName) {
      case 'select':
        phase = _inSelectPhase;
        return;
      case 'td':
        phase = _inCellPhase;
        return;
      case 'th':
        phase = _inCellPhase;
        return;
      case 'tr':
        phase = _inRowPhase;
        return;
      case 'tbody':
        phase = _inTableBodyPhase;
        return;
      case 'thead':
        phase = _inTableBodyPhase;
        return;
      case 'tfoot':
        phase = _inTableBodyPhase;
        return;
      case 'caption':
        phase = _inCaptionPhase;
        return;
      case 'colgroup':
        phase = _inColumnGroupPhase;
        return;
      case 'table':
        phase = _inTablePhase;
        return;
      case 'head':
        phase = _inBodyPhase;
        return;
      case 'body':
        phase = _inBodyPhase;
        return;
      case 'frameset':
        phase = _inFramesetPhase;
        return;
      case 'html':
        phase = _beforeHeadPhase;
        return;
    }
  }
  phase = _inBodyPhase;
}