endTagOptgroup method

void endTagOptgroup(
  1. EndTagToken token
)

Implementation

void endTagOptgroup(EndTagToken token) {
  // </optgroup> implicitly closes <option>
  if (tree.openElements.last.localName == 'option' &&
      tree.openElements[tree.openElements.length - 2].localName ==
          'optgroup') {
    tree.openElements.removeLast();
  }
  // It also closes </optgroup>
  if (tree.openElements.last.localName == 'optgroup') {
    final node = tree.openElements.removeLast();
    node.endSourceSpan = token.span;
    // But nothing else
  } else {
    parser.parseError(
        token.span, 'unexpected-end-tag-in-select', {'name': 'optgroup'});
  }
}