From 5392cbe5a4d195a2951dfba36accee4d4fcd65e7 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Sun, 14 Apr 2019 00:43:18 +0100 Subject: [PATCH] resourceloader: Switch params for private addLink() function I don't recall how this awkward parameter order came about, but it easy to change given it is a private function. Switching the order makes it cleaner to then internally re-use for mw.loader.load() which currently contains a duplicate version of this logic. Change-Id: Id686389991315c3d05222f8fd0b69f93f65e9924 --- resources/src/startup/mediawiki.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/resources/src/startup/mediawiki.js b/resources/src/startup/mediawiki.js index f961da2652..676a1398aa 100644 --- a/resources/src/startup/mediawiki.js +++ b/resources/src/startup/mediawiki.js @@ -1156,10 +1156,11 @@ * Utility function for execute() * * @ignore - * @param {string} [media] Media attribute * @param {string} url URL + * @param {string} [media] Media attribute + * @param {Node|null} [nextNode] */ - function addLink( media, url ) { + function addLink( url, media, nextNode ) { var el = document.createElement( 'link' ); el.rel = 'stylesheet'; @@ -1170,8 +1171,8 @@ // see #addEmbeddedCSS, T33676, T43331, and T49277 for details. el.href = url; - if ( marker && marker.parentNode ) { - marker.parentNode.insertBefore( el, marker ); + if ( nextNode && nextNode.parentNode ) { + nextNode.parentNode.insertBefore( el, nextNode ); } else { document.head.appendChild( el ); } @@ -1425,7 +1426,7 @@ for ( i = 0; i < value.length; i++ ) { if ( key === 'bc-url' ) { // back-compat: { : [url, ..] } - addLink( media, value[ i ] ); + addLink( value[ i ], media, marker ); } else if ( key === 'css' ) { // { "css": [css, ..] } addEmbeddedCSS( value[ i ], cssHandle() ); @@ -1438,7 +1439,7 @@ for ( media in value ) { urls = value[ media ]; for ( i = 0; i < urls.length; i++ ) { - addLink( media, urls[ i ] ); + addLink( urls[ i ], media, marker ); } } } -- 2.20.1