resourceloader: avoid use of $.globalEval in mediawiki.js
authorAaron Schulz <aschulz@wikimedia.org>
Thu, 10 May 2018 19:46:23 +0000 (12:46 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 12 May 2018 01:34:27 +0000 (01:34 +0000)
Bug: T192623
Change-Id: Icdd5d76546a6c265a8e941c4e9b28f73bf9dd028

resources/src/mediawiki/mediawiki.js

index fbe8af2..486fb80 100644 (file)
                                }
                        }
 
+                       /**
+                        * @private
+                        * @param {string} code JavaScript code
+                        */
+                       function domEval( code ) {
+                               var script = document.createElement( 'script' );
+                               script.text = code;
+                               document.head.appendChild( script );
+                               script.parentNode.removeChild( script );
+                       }
+
                        /**
                         * Executes a loaded module, making it ready to use
                         *
                                                        // Site and user modules are legacy scripts that run in the global scope.
                                                        // This is transported as a string instead of a function to avoid needing
                                                        // to use string manipulation to undo the function wrapper.
-                                                       $.globalEval( script );
+                                                       domEval( script );
                                                        markModuleReady();
 
                                                } else {
                                }
                                mw.requestIdleCallback( function () {
                                        try {
-                                               $.globalEval( implementations.join( ';' ) );
+                                               domEval( implementations.join( ';' ) );
                                        } catch ( err ) {
                                                cb( err );
                                        }