mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-12 09:21:11 +00:00
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:
parent
5e02d2b7ea
commit
f79e97cf6b
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue