Makes the promise method of Deferreds a bit more readable by not using the variable...
[jquery.git] / src / core.js
index 422b688..31330e8 100644 (file)
@@ -294,7 +294,7 @@ jQuery.fn = jQuery.prototype = {
 jQuery.fn.init.prototype = jQuery.fn;
 
 jQuery.extend = jQuery.fn.extend = function() {
-        var options, name, src, copy, copyIsArray, clone,
+       var options, name, src, copy, copyIsArray, clone,
                target = arguments[0] || {},
                i = 1,
                length = arguments.length,
@@ -566,10 +566,8 @@ jQuery.extend({
                if ( data && rnotwhite.test(data) ) {
                        // Inspired by code by Andrea Giammarchi
                        // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
-                       var head = document.getElementsByTagName("head")[0] || document.documentElement,
-                               script = document.createElement("script");
-
-                       script.type = "text/javascript";
+                       var head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement,
+                               script = document.createElement( "script" );
 
                        if ( jQuery.support.scriptEval() ) {
                                script.appendChild( document.createTextNode( data ) );
@@ -892,14 +890,14 @@ jQuery.extend({
                        isRejected: failDeferred.isResolved,
                        // Get a promise for this deferred
                        // If obj is provided, the promise aspect is added to the object
-                       promise: function( obj , i /* internal */ ) {
+                       promise: function( obj ) {
                                if ( obj == null ) {
                                        if ( promise ) {
                                                return promise;
                                        }
                                        promise = obj = {};
                                }
-                               i = promiseMethods.length;
+                               var i = promiseMethods.length;
                                while( i-- ) {
                                        obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
                                }
@@ -957,18 +955,20 @@ jQuery.extend({
                return { browser: match[1] || "", version: match[2] || "0" };
        },
 
-       subclass: function(){
+       sub: function() {
                function jQuerySubclass( selector, context ) {
                        return new jQuerySubclass.fn.init( selector, context );
                }
+               jQuery.extend( true, jQuerySubclass, this );
                jQuerySubclass.superclass = this;
                jQuerySubclass.fn = jQuerySubclass.prototype = this();
                jQuerySubclass.fn.constructor = jQuerySubclass;
                jQuerySubclass.subclass = this.subclass;
                jQuerySubclass.fn.init = function init( selector, context ) {
-                       if (context && context instanceof jQuery && !(context instanceof jQuerySubclass)){
+                       if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
                                context = jQuerySubclass(context);
                        }
+
                        return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
                };
                jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
@@ -1050,6 +1050,6 @@ function doScrollCheck() {
 }
 
 // Expose jQuery to the global object
-return (window.jQuery = window.$ = jQuery);
+return jQuery;
 
 })();