]> source.dussan.org Git - jquery.git/commitdiff
compress -16 min+gzip
authorRichard Gibson <richard.gibson@gmail.com>
Thu, 13 Dec 2012 17:40:55 +0000 (12:40 -0500)
committerRichard Gibson <richard.gibson@gmail.com>
Thu, 13 Dec 2012 17:41:25 +0000 (12:41 -0500)
src/css.js
src/manipulation.js

index b39b58ee6110a7b0c5f4f7ddafff5770daf40039..210bed2e803e0d54cce514e8699f772ac1276973 100644 (file)
@@ -273,7 +273,7 @@ jQuery.extend({
        },
 
        // A method for quickly swapping in/out CSS properties to get correct calculations
-       swap: function( elem, options, callback ) {
+       swap: function( elem, options, callback, args ) {
                var ret, name,
                        old = {};
 
@@ -283,7 +283,7 @@ jQuery.extend({
                        elem.style[ name ] = options[ name ];
                }
 
-               ret = callback.call( elem );
+               ret = callback.apply( elem, args || [] );
 
                // Revert the old values
                for ( name in options ) {
@@ -524,13 +524,11 @@ jQuery.each([ "height", "width" ], function( i, name ) {
                        if ( computed ) {
                                // certain elements can have dimension info if we invisibly show them
                                // however, it must have a current display style that would benefit from this
-                               if ( elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ) {
-                                       return jQuery.swap( elem, cssShow, function() {
+                               return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ?
+                                       jQuery.swap( elem, cssShow, function() {
                                                return getWidthOrHeight( elem, name, extra );
-                                       });
-                               } else {
-                                       return getWidthOrHeight( elem, name, extra );
-                               }
+                                       }) :
+                                       getWidthOrHeight( elem, name, extra );
                        }
                },
 
@@ -599,13 +597,12 @@ jQuery(function() {
        if ( !jQuery.support.reliableMarginRight ) {
                jQuery.cssHooks.marginRight = {
                        get: function( elem, computed ) {
-                               // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
-                               // Work around by temporarily setting element display to inline-block
-                               return jQuery.swap( elem, { "display": "inline-block" }, function() {
-                                       if ( computed ) {
-                                               return curCSS( elem, "marginRight" );
-                                       }
-                               });
+                               if ( computed ) {
+                                       // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
+                                       // Work around by temporarily setting element display to inline-block
+                                       return jQuery.swap( elem, { "display": "inline-block" },
+                                               curCSS, [ elem, "marginRight" ] );
+                               }
                        }
                };
        }
@@ -617,11 +614,12 @@ jQuery(function() {
                jQuery.each( [ "top", "left" ], function( i, prop ) {
                        jQuery.cssHooks[ prop ] = {
                                get: function( elem, computed ) {
-                                       var ret;
                                        if ( computed ) {
-                                               ret = curCSS( elem, prop );
+                                               computed = curCSS( elem, prop );
                                                // if curCSS returns percentage, fallback to offset
-                                               return rnumnonpx.test( ret ) ? jQuery( elem ).position()[ prop ] + "px" : ret;
+                                               return rnumnonpx.test( computed ) ?
+                                                       jQuery( elem ).position()[ prop ] + "px" :
+                                                       computed;
                                        }
                                }
                        };
@@ -649,10 +647,10 @@ jQuery.each({
        jQuery.cssHooks[ prefix + suffix ] = {
                expand: function( value ) {
                        var i = 0,
+                               expanded = {},
 
                                // assumes a single number if not a string
-                               parts = typeof value === "string" ? value.split(" ") : [ value ],
-                               expanded = {};
+                               parts = typeof value === "string" ? value.split(" ") : [ value ];
 
                        for ( ; i < 4; i++ ) {
                                expanded[ prefix + cssExpand[ i ] + suffix ] =
index ec7a0c16b7455f203287c8404402865136e6b972..0625277087e57e73283e5e4c8904fa3010dc245d 100644 (file)
@@ -283,9 +283,10 @@ jQuery.fn.extend({
                // Flatten any nested arrays
                args = core_concat.apply( [], args );
 
-               var fragment, first, scripts, hasScripts, iNoClone, node, doc,
+               var fragment, first, scripts, hasScripts, node, doc,
                        i = 0,
                        l = this.length,
+                       iNoClone = l - 1,
                        value = args[0],
                        isFunction = jQuery.isFunction( value );
 
@@ -317,7 +318,7 @@ jQuery.fn.extend({
 
                                // Use the original fragment for the last item instead of the first because it can end up
                                // being emptied incorrectly in certain situations (#8070).
-                               for ( iNoClone = l - 1; i < l; i++ ) {
+                               for ( ; i < l; i++ ) {
                                        node = fragment;
 
                                        if ( i !== iNoClone ) {
@@ -514,13 +515,15 @@ jQuery.each({
                        insert = jQuery( selector ),
                        last = insert.length - 1;
 
-                       for ( ; i <= last; i++ ) {
-                               elems = i === last ? this : this.clone(true);
-                               jQuery( insert[i] )[ original ]( elems );
-                               core_push.apply( ret, elems.get() );
-                       }
+               for ( ; i <= last; i++ ) {
+                       elems = i === last ? this : this.clone(true);
+                       jQuery( insert[i] )[ original ]( elems );
+
+                       // Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
+                       core_push.apply( ret, elems.get() );
+               }
 
-                       return this.pushStack( ret );
+               return this.pushStack( ret );
        };
 });
 
@@ -610,9 +613,8 @@ jQuery.extend({
        },
 
        clean: function( elems, context, fragment, scripts, selection ) {
-               var elem, j, tmp, tag, wrap, tbody,
+               var elem, i, j, tmp, tag, wrap, tbody,
                        ret = [],
-                       i = 0,
                        safe = context === document && safeFragment;
 
                // Ensure that context is a document
@@ -706,7 +708,7 @@ jQuery.extend({
                                // Append to fragment
                                // #4087 - If origin and destination elements are the same, and this is
                                // that element, do not append to fragment
-                               if ( !( selection && jQuery.inArray( elem, selection ) !== -1 ) ) {
+                               if ( !selection || jQuery.inArray( elem, selection ) === -1 ) {
                                        fragment.appendChild( elem );
                                }
                                tmp = getAll( elem, "script" );