* Closes the nearest element with the tag name `fullName` in the parse tree. * `endSourceSpan` is the span of the closing tag, or null if the element does * not have a closing tag (for example, this happens when an incomplete * opening tag is recovered).
(
expectedName: string | null,
expectedType: NodeContainerConstructor,
endSourceSpan: ParseSourceSpan | null,
)
| 608 | * opening tag is recovered). |
| 609 | */ |
| 610 | private _popContainer( |
| 611 | expectedName: string | null, |
| 612 | expectedType: NodeContainerConstructor, |
| 613 | endSourceSpan: ParseSourceSpan | null, |
| 614 | ): boolean { |
| 615 | let unexpectedCloseTagDetected = false; |
| 616 | for (let stackIndex = this._containerStack.length - 1; stackIndex >= 0; stackIndex--) { |
| 617 | const node = this._containerStack[stackIndex]; |
| 618 | const nodeName = node instanceof html.Component ? node.fullName : node.name; |
| 619 | |
| 620 | if ((nodeName === expectedName || expectedName === null) && node instanceof expectedType) { |
| 621 | // Record the parse span with the element that is being closed. Any elements that are |
| 622 | // removed from the element stack at this point are closed implicitly, so they won't get |
| 623 | // an end source span (as there is no explicit closing element). |
| 624 | node.endSourceSpan = endSourceSpan; |
| 625 | node.sourceSpan.end = endSourceSpan !== null ? endSourceSpan.end : node.sourceSpan.end; |
| 626 | this._containerStack.splice(stackIndex, this._containerStack.length - stackIndex); |
| 627 | return !unexpectedCloseTagDetected; |
| 628 | } |
| 629 | |
| 630 | // Blocks and most elements are not self closing. |
| 631 | if (node instanceof html.Block || !this._getTagDefinition(node)?.closedByParent) { |
| 632 | // Note that we encountered an unexpected close tag but continue processing the element |
| 633 | // stack so we can assign an `endSourceSpan` if there is a corresponding start tag for this |
| 634 | // end tag in the stack. |
| 635 | unexpectedCloseTagDetected = true; |
| 636 | } |
| 637 | } |
| 638 | return false; |
| 639 | } |
| 640 | |
| 641 | private _consumeAttr(attrName: AttributeNameToken): html.Attribute { |
| 642 | const fullName = mergeNsAndName(attrName.parts[0], attrName.parts[1]); |
no test coverage detected