Remove unreachable code in tableOfContents.js

AFAICT the `setInnerHTML` param that was part of the reloadPartialHTML
method was always true. Thus, much of the code contained in this method
can be removed and the `setInnerHTML` param can also be removed.

Bug: T316571
Change-Id: I82e99f902eadba8a9df2166c4f89ba1f1d747a47
This commit is contained in:
Nicholas Ray 2022-09-12 17:45:24 -06:00
parent 5e02d2b7ea
commit f79e97cf6b
1 changed files with 2 additions and 20 deletions

View File

@ -433,29 +433,11 @@ module.exports = function tableOfContents( props ) {
*
* @param {string} elementId
* @param {string} html
* @param {boolean} setInnerHTML
*/
function reloadPartialHTML( elementId, html, setInnerHTML = true ) {
function reloadPartialHTML( elementId, html ) {
const htmlElement = document.getElementById( elementId );
if ( htmlElement ) {
if ( setInnerHTML ) {
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 );
}
}
}
htmlElement.innerHTML = html;
}
}