Commit 8f7db68c authored by Timmy Willison's avatar Timmy Willison

Fixes #14549. Execute the factory immediately when CommonJS is used in the browser.

parent 6fde9752
...@@ -15,12 +15,16 @@ ...@@ -15,12 +15,16 @@
(function( window, factory ) { (function( window, factory ) {
if ( typeof module === "object" && typeof module.exports === "object" ) { if ( typeof module === "object" && typeof module.exports === "object" ) {
// Expose a jQuery-making factory as module.exports in loaders that implement the Node // For CommonJS and CommonJS-like environments where a proper window is present,
// module pattern (including browserify). // execute the factory and get jQuery
// This accentuates the need for a real window in the environment // For environments that do not inherently posses a window with a document
// (such as Node.js), expose a jQuery-making factory as module.exports
// This accentuates the need for the creation of a real window
// e.g. var jQuery = require("jquery")(window); // e.g. var jQuery = require("jquery")(window);
module.exports = function( w ) { // See ticket #14549 for more info
w = w || window; module.exports = window.document ?
factory( window ) :
function( w ) {
if ( !w.document ) { if ( !w.document ) {
throw new Error("jQuery requires a window with a document"); throw new Error("jQuery requires a window with a document");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment