Merge "Remove unreachable code in tableOfContents.js"

This commit is contained in:
jenkins-bot 2022-09-19 16:44:26 +00:00 committed by Gerrit Code Review
commit 95dbf57db5

View file

@ -433,29 +433,11 @@ module.exports = function tableOfContents( props ) {
* *
* @param {string} elementId * @param {string} elementId
* @param {string} html * @param {string} html
* @param {boolean} setInnerHTML
*/ */
function reloadPartialHTML( elementId, html, setInnerHTML = true ) { function reloadPartialHTML( elementId, html ) {
const htmlElement = document.getElementById( elementId ); const htmlElement = document.getElementById( elementId );
if ( htmlElement ) { if ( htmlElement ) {
if ( setInnerHTML ) { htmlElement.innerHTML = html;
htmlElement.innerHTML = html;
} else if ( htmlElement.outerHTML ) {
htmlElement.outerHTML = html;
} else { // IF outerHTML property access is not supported
const tmpContainer = document.createElement( 'div' );
tmpContainer.innerHTML = html.trim();
const childNode = tmpContainer.firstChild;
if ( childNode ) {
const tmpElement = document.createElement( 'div' );
tmpElement.setAttribute( 'id', `div-tmp-${elementId}` );
const parentNode = htmlElement.parentNode;
if ( parentNode ) {
parentNode.replaceChild( tmpElement, htmlElement );
parentNode.replaceChild( childNode, tmpElement );
}
}
}
} }
} }