Skip to content

Commit

Permalink
Make sure that jQuery works even when the individual modules are load…
Browse files Browse the repository at this point in the history
…ed separately AND jQuery.noConflict(true) is used. Fixes #7011.
  • Loading branch information
jeresig committed Sep 8, 2010
1 parent b920f0a commit a44ec40
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/ajax.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var jsc = jQuery.now(), var jsc = jQuery.now(),
rscript = /<script(.|\s)*?\/script>/gi, rscript = /<script(.|\s)*?\/script>/gi,
rselectTextarea = /select|textarea/i, rselectTextarea = /select|textarea/i,
Expand Down Expand Up @@ -686,3 +688,5 @@ jQuery.extend( jQuery.ajax, {


// For backwards compatibility // For backwards compatibility
jQuery.extend( jQuery.ajax ); jQuery.extend( jQuery.ajax );

})( jQuery );
4 changes: 4 additions & 0 deletions src/attributes.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var rclass = /[\n\t]/g, var rclass = /[\n\t]/g,
rspace = /\s+/, rspace = /\s+/,
rreturn = /\r/g, rreturn = /\r/g,
Expand Down Expand Up @@ -341,3 +343,5 @@ jQuery.extend({
} }
} }
}); });

})( jQuery );
4 changes: 4 additions & 0 deletions src/css.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var ralpha = /alpha\([^)]*\)/, var ralpha = /alpha\([^)]*\)/,
ropacity = /opacity=([^)]*)/, ropacity = /opacity=([^)]*)/,
rdashAlpha = /-([a-z])/ig, rdashAlpha = /-([a-z])/ig,
Expand Down Expand Up @@ -238,3 +240,5 @@ if ( jQuery.expr && jQuery.expr.filters ) {
return !jQuery.expr.filters.hidden( elem ); return !jQuery.expr.filters.hidden( elem );
}; };
} }

})( jQuery );
4 changes: 4 additions & 0 deletions src/data.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var windowData = {}; var windowData = {};


jQuery.extend({ jQuery.extend({
Expand Down Expand Up @@ -165,3 +167,5 @@ jQuery.fn.extend({
}); });
} }
}); });

})( jQuery );
4 changes: 4 additions & 0 deletions src/dimensions.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

// Create innerHeight, innerWidth, outerHeight and outerWidth methods // Create innerHeight, innerWidth, outerHeight and outerWidth methods
jQuery.each([ "Height", "Width" ], function( i, name ) { jQuery.each([ "Height", "Width" ], function( i, name ) {


Expand Down Expand Up @@ -55,3 +57,5 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
}; };


}); });

})( jQuery );
4 changes: 4 additions & 0 deletions src/effects.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var elemdisplay = {}, var elemdisplay = {},
rfxtypes = /toggle|show|hide/, rfxtypes = /toggle|show|hide/,
rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/, rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/,
Expand Down Expand Up @@ -480,3 +482,5 @@ if ( jQuery.expr && jQuery.expr.filters ) {
}).length; }).length;
}; };
} }

})( jQuery );
4 changes: 4 additions & 0 deletions src/event.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var rnamespaces = /\.(.*)$/, var rnamespaces = /\.(.*)$/,
fcleanup = function( nm ) { fcleanup = function( nm ) {
return nm.replace(/[^\w\s\.\|`]/g, function( ch ) { return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
Expand Down Expand Up @@ -1109,3 +1111,5 @@ if ( window.attachEvent && !window.addEventListener ) {
} }
}); });
} }

})( jQuery );
6 changes: 5 additions & 1 deletion src/manipulation.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rleadingWhitespace = /^\s+/, rleadingWhitespace = /^\s+/,
rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
Expand Down Expand Up @@ -599,4 +601,6 @@ function evalScript( i, elem ) {
if ( elem.parentNode ) { if ( elem.parentNode ) {
elem.parentNode.removeChild( elem ); elem.parentNode.removeChild( elem );
} }
} }

})( jQuery );
4 changes: 4 additions & 0 deletions src/offset.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

if ( "getBoundingClientRect" in document.documentElement ) { if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) { jQuery.fn.offset = function( options ) {
var elem = this[0]; var elem = this[0];
Expand Down Expand Up @@ -281,3 +283,5 @@ function getWindow( elem ) {
elem.defaultView || elem.parentWindow : elem.defaultView || elem.parentWindow :
false; false;
} }

})( jQuery );
4 changes: 4 additions & 0 deletions src/queue.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

jQuery.extend({ jQuery.extend({
queue: function( elem, type, data ) { queue: function( elem, type, data ) {
if ( !elem ) { if ( !elem ) {
Expand Down Expand Up @@ -88,3 +90,5 @@ jQuery.fn.extend({
return this.queue( type || "fx", [] ); return this.queue( type || "fx", [] );
} }
}); });

})( jQuery );
6 changes: 5 additions & 1 deletion src/support.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

(function() { (function() {


jQuery.support = {}; jQuery.support = {};
Expand Down Expand Up @@ -132,7 +134,7 @@


// release memory in IE // release memory in IE
root = script = div = all = a = null; root = script = div = all = a = null;
})(); })( jQuery );


jQuery.props = { jQuery.props = {
"for": "htmlFor", "for": "htmlFor",
Expand All @@ -146,3 +148,5 @@ jQuery.props = {
usemap: "useMap", usemap: "useMap",
frameborder: "frameBorder" frameborder: "frameBorder"
}; };

})( jQuery );
4 changes: 4 additions & 0 deletions src/traversing.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

var runtil = /Until$/, var runtil = /Until$/,
rparentsprev = /^(?:parents|prevUntil|prevAll)/, rparentsprev = /^(?:parents|prevUntil|prevAll)/,
// Note: This RegExp should be improved, or likely pulled from Sizzle // Note: This RegExp should be improved, or likely pulled from Sizzle
Expand Down Expand Up @@ -271,3 +273,5 @@ function winnow( elements, qualifier, keep ) {
return (jQuery.inArray( elem, qualifier ) >= 0) === keep; return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
}); });
} }

})( jQuery );
3 changes: 2 additions & 1 deletion test/unit/core.js
Expand Up @@ -183,7 +183,7 @@ test("browser", function() {
} }


test("noConflict", function() { test("noConflict", function() {
expect(6); expect(7);


var $$ = jQuery; var $$ = jQuery;


Expand All @@ -196,6 +196,7 @@ test("noConflict", function() {
equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" ); equals( jQuery.noConflict(true), $$, "noConflict returned the jQuery object" );
equals( jQuery, originaljQuery, "Make sure jQuery was reverted." ); equals( jQuery, originaljQuery, "Make sure jQuery was reverted." );
equals( $, original$, "Make sure $ was reverted." ); equals( $, original$, "Make sure $ was reverted." );
ok( $$("#main").html("test"), "Make sure that jQuery still works." );


jQuery = $$; jQuery = $$;
}); });
Expand Down

0 comments on commit a44ec40

Please sign in to comment.