Skip to content
Permalink
Browse files

Make sure that jQuery works even when the individual modules are load…

…ed separately AND jQuery.noConflict(true) is used. Fixes #7011.
  • Loading branch information
jeresig committed Sep 8, 2010
1 parent 116f3b7 commit bca576550249e9b79b1097669dff6d4ddd0d65cf
Showing with 51 additions and 2 deletions.
  1. +4 −0 src/ajax.js
  2. +4 −0 src/attributes.js
  3. +4 −0 src/css.js
  4. +4 −0 src/data.js
  5. +4 −0 src/dimensions.js
  6. +4 −0 src/effects.js
  7. +4 −0 src/event.js
  8. +5 −1 src/manipulation.js
  9. +4 −0 src/offset.js
  10. +4 −0 src/queue.js
  11. +4 −0 src/support.js
  12. +4 −0 src/traversing.js
  13. +2 −1 test/unit/core.js
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

var rclass = /[\n\t]/g,
rspace = /\s+/,
rreturn = /\r/g,
@@ -345,3 +347,5 @@ jQuery.extend({
return jQuery.style( elem, name, value );
}
});

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

// exclude the following css properties to add px
var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
ralpha = /alpha\([^)]*\)/,
@@ -232,3 +234,5 @@ if ( jQuery.expr && jQuery.expr.filters ) {
return !jQuery.expr.filters.hidden( elem );
};
}

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

var windowData = {};

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

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

});

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

(function() {

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

})( jQuery );
@@ -1,3 +1,5 @@
(function( jQuery ) {

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

})( jQuery );
@@ -183,7 +183,7 @@ test("browser", function() {
}

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

var $$ = jQuery;

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

jQuery = $$;
});

7 comments on commit bca5765

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Sep 8, 2010

Note that I will be adding some code to strip these function wrappers off during the build process so that the final jquery.js will be smaller in size.

@cowboy

This comment has been minimized.

Copy link
Member

cowboy replied Sep 8, 2010

During the build process, you're going to remove the surrounding closure from core.js as well, so that jquery.js is smaller in size, and actually works when noConflict( true ) is called, right? (just double-checking)

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Sep 8, 2010

How does this work with shared private variables across modules ?

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Sep 8, 2010

@jdalton: The vast majority of the shared private variables were removed back in March - some additional tinkering will need to be done to tackle the remaining few but it shouldn't be bad. I'm actually working on it right now.

@jdalton

This comment has been minimized.

Copy link
Member

jdalton replied Sep 8, 2010

Woot! I should probably look into this for FuseJS too. I currently share a lot of variables between modules and rely on a custom build process like MooTools to keep the primary closure. I feel like singing a little Boys II Men for the memory of the private variables awesomeness :{D

@helianthus

This comment has been minimized.

Copy link

helianthus replied Sep 11, 2010

I have just noticed that this commit breaks jQuery.animate since some variables like rdashAlpha and fcamelCase are now undefined.

@jeresig

This comment has been minimized.

Copy link
Member Author

jeresig replied Sep 12, 2010

@helianthus: Actually already fixed it - but just noticed that it was in a separate branch. You can see it over here: a166860 (it will be merged into the main branch very soon)

Please sign in to comment.
You can’t perform that action at this time.