mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Fixes #14549. Execute the factory immediately when CommonJS is used in the browser.
This commit is contained in:
parent
9cf253891e
commit
54419cb5ad
24
src/intro.js
24
src/intro.js
@ -15,17 +15,21 @@
|
|||||||
(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 ?
|
||||||
if ( !w.document ) {
|
factory( window ) :
|
||||||
throw new Error("jQuery requires a window with a document");
|
function( w ) {
|
||||||
}
|
if ( !w.document ) {
|
||||||
return factory( w );
|
throw new Error("jQuery requires a window with a document");
|
||||||
};
|
}
|
||||||
|
return factory( w );
|
||||||
|
};
|
||||||
} else {
|
} else {
|
||||||
factory( window );
|
factory( window );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user