From bca576550249e9b79b1097669dff6d4ddd0d65cf Mon Sep 17 00:00:00 2001 From: jeresig Date: Wed, 8 Sep 2010 13:54:33 -0400 Subject: [PATCH] Make sure that jQuery works even when the individual modules are loaded separately AND jQuery.noConflict(true) is used. Fixes #7011. --- src/ajax.js | 4 ++++ src/attributes.js | 4 ++++ src/css.js | 4 ++++ src/data.js | 4 ++++ src/dimensions.js | 4 ++++ src/effects.js | 4 ++++ src/event.js | 4 ++++ src/manipulation.js | 6 +++++- src/offset.js | 4 ++++ src/queue.js | 4 ++++ src/support.js | 4 ++++ src/traversing.js | 4 ++++ test/unit/core.js | 3 ++- 13 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/ajax.js b/src/ajax.js index 2c4f13cb..52a5a22c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,3 +1,5 @@ +(function( jQuery ) { + var jsc = jQuery.now(), rscript = //gi, rselectTextarea = /select|textarea/i, @@ -686,3 +688,5 @@ jQuery.extend( jQuery.ajax, { // For backwards compatibility jQuery.extend( jQuery.ajax ); + +})( jQuery ); diff --git a/src/attributes.js b/src/attributes.js index 719c368a..73b4cdf1 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -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 ); diff --git a/src/css.js b/src/css.js index cb65c0ba..ae6853e9 100644 --- a/src/css.js +++ b/src/css.js @@ -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 ); diff --git a/src/data.js b/src/data.js index d38d47d3..5404c936 100644 --- a/src/data.js +++ b/src/data.js @@ -1,3 +1,5 @@ +(function( jQuery ) { + var windowData = {}; jQuery.extend({ @@ -165,3 +167,5 @@ jQuery.fn.extend({ }); } }); + +})( jQuery ); diff --git a/src/dimensions.js b/src/dimensions.js index aeaaa78b..de10832d 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -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 ); diff --git a/src/effects.js b/src/effects.js index 40326e23..65b9e0f9 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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 ); diff --git a/src/event.js b/src/event.js index 45f2202c..f0b27de4 100644 --- a/src/event.js +++ b/src/event.js @@ -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 ); diff --git a/src/manipulation.js b/src/manipulation.js index cb898cc3..3054eea1 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -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 ); } -} \ No newline at end of file +} + +})( jQuery ); diff --git a/src/offset.js b/src/offset.js index 0ce4c197..c38a7f21 100644 --- a/src/offset.js +++ b/src/offset.js @@ -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 ); diff --git a/src/queue.js b/src/queue.js index e52f37b8..11c658f5 100644 --- a/src/queue.js +++ b/src/queue.js @@ -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 ); diff --git a/src/support.js b/src/support.js index cddd3dc3..75e89dd0 100644 --- a/src/support.js +++ b/src/support.js @@ -1,3 +1,5 @@ +(function( jQuery ) { + (function() { jQuery.support = {}; @@ -146,3 +148,5 @@ jQuery.props = { usemap: "useMap", frameborder: "frameBorder" }; + +})( jQuery ); diff --git a/src/traversing.js b/src/traversing.js index fde7219b..59110b09 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -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 ); diff --git a/test/unit/core.js b/test/unit/core.js index 3ba16a48..811d13fb 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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 = $$; });