X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=2b00627dbee3af23d20afcf838baf78c8d29c07b;hb=8ebb9b22df32fe5739a48087b6e33abb9f5cda49;hp=5a005556239c376990be52733e617154f71b01c6;hpb=94f35d05199ec1634d9c8c60d10f298f260056bd;p=jquery.git diff --git a/src/core.js b/src/core.js index 5a00555..2b00627 100644 --- a/src/core.js +++ b/src/core.js @@ -1,4 +1,4 @@ -(function() { +var jQuery = (function() { // Define a local copy of jQuery var jQuery = function( selector, context ) { @@ -109,7 +109,7 @@ jQuery.fn = jQuery.prototype = { } } else { - ret = buildFragment( [ match[1] ], [ doc ] ); + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; } @@ -119,7 +119,9 @@ jQuery.fn = jQuery.prototype = { } else { elem = document.getElementById( match[2] ); - if ( elem ) { + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { // Handle the case where IE and Opera return items // by name instead of ID if ( elem.id !== match[2] ) { @@ -358,11 +360,20 @@ jQuery.extend({ // Is the DOM ready to be used? Set to true once it occurs. isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, // Handle when the DOM is ready - ready: function() { + ready: function( wait ) { + // A third-party is pushing the ready event forwards + if ( wait === true ) { + jQuery.readyWait--; + } + // Make sure that the DOM is not already loaded - if ( !jQuery.isReady ) { + if ( !jQuery.readyWait && !jQuery.isReady ) { // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). if ( !document.body ) { return setTimeout( jQuery.ready, 13 ); @@ -371,6 +382,11 @@ jQuery.extend({ // Remember that the DOM is ready jQuery.isReady = true; + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + // If there are functions bound, to execute if ( readyList ) { // Execute all of them @@ -441,12 +457,14 @@ jQuery.extend({ return jQuery.type(obj) === "function"; }, - isArray: function( obj ) { + isArray: Array.isArray || function( obj ) { return jQuery.type(obj) === "array"; }, type: function( obj ) { - return toString.call(obj).slice(8, -1).toLowerCase(); + return obj == null ? + String( obj ) : + toString.call(obj).slice(8, -1).toLowerCase(); }, isPlainObject: function( obj ) { @@ -601,7 +619,7 @@ jQuery.extend({ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 var type = jQuery.type(array); - if ( array.length == null || type === "string" || type === "function" || type === "regexp" || (typeof type !== "function" && array.setInterval) ) { + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || "setInterval" in array ) { push.call( ret, array ); } else { jQuery.merge( ret, array ); @@ -822,6 +840,6 @@ function doScrollCheck() { } // Expose jQuery to the global object -window.jQuery = window.$ = jQuery; +return (window.jQuery = window.$ = jQuery); })();