Made a bunch of changes to the way that the $() compatability code is handled.
This commit is contained in:
parent
05a4b784e8
commit
abf3054667
57
jquery/jquery.js
vendored
57
jquery/jquery.js
vendored
|
@ -12,11 +12,35 @@
|
|||
// Global undefined variable
|
||||
window.undefined = window.undefined;
|
||||
|
||||
// Map over the $ in case of overwrite
|
||||
if ( $ ) var ._$ = $;
|
||||
|
||||
/**
|
||||
* Create a new jQuery Object
|
||||
* @constructor
|
||||
*/
|
||||
function jQuery(a,c) {
|
||||
var $ = jQuery = function(a,c) {
|
||||
/*
|
||||
* Handle support for overriding other $() functions. Way too many libraries
|
||||
* provide this function to simply ignore it and overwrite it.
|
||||
*/
|
||||
|
||||
// Check to see if this is a possible collision case
|
||||
if ( _$ && !c && ( a.constructor == String &&
|
||||
|
||||
// Make sure that the expression is a colliding one
|
||||
!/[^a-zA-Z0-9_-]/.test(a) &&
|
||||
|
||||
// and that there are no elements that match it
|
||||
// (this is the one truly ambiguous case)
|
||||
!document.getElementsByTagName(a).length ) ||
|
||||
|
||||
// Watch for an array being passed in (Prototype 1.5)
|
||||
a.constructor == Array )
|
||||
|
||||
// Use the default method, in case it works some voodoo
|
||||
return _$( a );
|
||||
|
||||
// Watch for when a jQuery object is passed in as an arg
|
||||
if ( a && a.jquery )
|
||||
return a;
|
||||
|
@ -32,37 +56,6 @@ function jQuery(a,c) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The jQuery query object.
|
||||
*/
|
||||
if ( !window.$ )
|
||||
var $ = jQuery;
|
||||
|
||||
/*
|
||||
* Handle support for overriding other $() functions. Way too many libraries
|
||||
* provide this function to simply ignore it and overwrite it.
|
||||
*/
|
||||
else
|
||||
var $ = function(a,c) {
|
||||
// Check to see if this is a possible collision case
|
||||
if ( !c && a.constructor == String &&
|
||||
|
||||
// Make sure that the expression is a colliding one
|
||||
!/[^a-zA-Z0-9_-]/.test(a) &&
|
||||
|
||||
// and that there are no elements that match it
|
||||
// (this is the one truly ambiguous case)
|
||||
!document.getElementsByTagName(a).length ) {
|
||||
|
||||
// Only return the element if it's found
|
||||
var obj = document.getElementById(a);
|
||||
if ( obj ) return obj;
|
||||
|
||||
}
|
||||
|
||||
return jQuery(a,c);
|
||||
};
|
||||
|
||||
jQuery.fn = jQuery.prototype = {
|
||||
/**
|
||||
* The current SVN version of jQuery.
|
||||
|
|
Loading…
Reference in a new issue