resourceloader: Switch params for private addLink() function
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 13 Apr 2019 23:43:18 +0000 (00:43 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Sun, 14 Apr 2019 00:09:14 +0000 (01:09 +0100)
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

index f961da2..676a139 100644 (file)
                         * 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';
                                // 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 );
                                }
                                                        for ( i = 0; i < value.length; i++ ) {
                                                                if ( key === 'bc-url' ) {
                                                                        // back-compat: { <media>: [url, ..] }
-                                                                       addLink( media, value[ i ] );
+                                                                       addLink( value[ i ], media, marker );
                                                                } else if ( key === 'css' ) {
                                                                        // { "css": [css, ..] }
                                                                        addEmbeddedCSS( value[ i ], cssHandle() );
                                                        for ( media in value ) {
                                                                urls = value[ media ];
                                                                for ( i = 0; i < urls.length; i++ ) {
-                                                                       addLink( media, urls[ i ] );
+                                                                       addLink( urls[ i ], media, marker );
                                                                }
                                                        }
                                                }