X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fcore.js;h=4c7b07eca87226591d2c87de4e75ab8f2e65911f;hb=616aceef84dca3960f6b78680f41bdcf85fa7838;hp=e0db81d8693852950f9dfe6220ee8066781c5b7a;hpb=5e2163085cd210767d93416d78b2dc47c8abd912;p=jquery.git diff --git a/src/core.js b/src/core.js index e0db81d..4c7b07e 100644 --- a/src/core.js +++ b/src/core.js @@ -1,9 +1,7 @@ // Define a local copy of jQuery var jQuery = function( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' - return arguments.length === 0 ? - rootjQuery : - new jQuery.fn.init( selector, context ); + return new jQuery.fn.init( selector, context ); }, // Map over jQuery in case of overwrite @@ -446,8 +444,8 @@ jQuery.extend({ // not own constructor property must be Object if ( obj.constructor - && !hasOwnProperty.call(obj, "constructor") - && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { + && !hasOwnProperty.call(obj, "constructor") + && !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) { return false; } @@ -483,7 +481,7 @@ jQuery.extend({ script.text = data; } - // Use insertBefore instead of appendChild to circumvent an IE6 bug. + // Use insertBefore instead of appendChild to circumvent an IE6 bug. // This arises when a base node is used (#2709). head.insertBefore( script, head.firstChild ); head.removeChild( script ); @@ -569,23 +567,20 @@ jQuery.extend({ }, merge: function( first, second ) { - var pos, i = second.length; + var i = first.length, j = 0; - // We have to get length this way when IE & Opera overwrite the length - // expando of getElementsByTagName - if ( i && i.nodeType ) { - for ( i = 0; second[i]; ++i ) {} - } - - pos = i + first.length; - - // Correct length for non Arrays - first.length = pos; - - while ( i ) { - first[ --pos ] = second[ --i ]; + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } } + first.length = i; + return first; }, @@ -621,19 +616,18 @@ jQuery.extend({ }, // Use of jQuery.browser is frowned upon. - // It's included for backwards compatibility and plugins, - // although they should work to migrate away. + // More details: http://docs.jquery.com/Utilities/jQuery.browser browser: { version: (/.*?(?:firefox|safari|opera|msie)[\/ ]([\d.]+)/.exec(userAgent) || [0,'0'])[1], safari: /safari/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), - firefox: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) + firefox: /firefox/.test( userAgent ) } }); // Deprecated -jQuery.browser.mozilla = jQuery.browser.firefox; +jQuery.browser.mozilla = /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ); if ( indexOf ) { jQuery.inArray = function( elem, array ) {