packages/parse5/lib/parser/index.js
function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
    const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
    const token = formattingElementEntry.token;
    const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);

    p._adoptNodes(furthestBlock, newElement);
    p.treeAdapter.appendChild(furthestBlock, newElement);

    p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);
    p.activeFormattingElements.removeEntry(formattingElementEntry);

    p.openElements.remove(formattingElementEntry.element);
    p.openElements.insertAfter(furthestBlock, newElement);
}
function aaReplaceFormattingElement(p, furthestBlock, formattingElementEntry) {
    const ns = p.treeAdapter.getNamespaceURI(formattingElementEntry.element);
    const token = formattingElementEntry.token;
    const newElement = p.treeAdapter.createElement(token.tagName, ns, token.attrs);

    p._adoptNodes(furthestBlock, newElement);
    p.treeAdapter.appendChild(furthestBlock, newElement);

    p.activeFormattingElements.insertElementAfterBookmark(newElement, formattingElementEntry.token);
    p.activeFormattingElements.removeEntry(formattingElementEntry);

    p.openElements.remove(formattingElementEntry.element);
    p.openElements.insertAfter(furthestBlock, newElement);
}
function aaReplaceFormattingElement ( p , furthestBlock , formattingElementEntry ) { const ns = p . treeAdapter . getNamespaceURI ( formattingElementEntry . element ) ; const token = formattingElementEntry . token ; const newElement = p . treeAdapter . createElement ( token . tagName , ns , token . attrs ) ; p . _adoptNodes ( furthestBlock , newElement ) ; p . treeAdapter . appendChild ( furthestBlock , newElement ) ; p . activeFormattingElements . insertElementAfterBookmark ( newElement , formattingElementEntry . token ) ; p . activeFormattingElements . removeEntry ( formattingElementEntry ) ; p . openElements . remove ( formattingElementEntry . element ) ; p . openElements . insertAfter ( furthestBlock , newElement ) ; }
Steps 15-19 of the algorithm
Steps 15 - 19 of the algorithm