]> source.dussan.org Git - jquery.git/commitdiff
CSS: Don't expose jQuery.swap
authorMichał Gołębiowski <m.goleb@gmail.com>
Mon, 30 Mar 2015 17:19:15 +0000 (19:19 +0200)
committerTimmy Willison <timmywillisn@gmail.com>
Mon, 13 Apr 2015 15:50:27 +0000 (11:50 -0400)
jQuery.swap was an undocumented API used only internally. With the modular
AMD system we currently have it's not necessary to expose this function
publicly under the jQuery object.

Fixes gh-2058
Closes gh-2182

src/css.js
src/css/swap.js [deleted file]
src/css/var/swap.js [new file with mode: 0644]

index 51cc297e661b48372f2fa7733dac34a2eac53435..83c133e4b05e8a006006b766cd633828d6dea85d 100644 (file)
@@ -7,6 +7,7 @@ define([
        "./css/var/rnumnonpx",
        "./css/var/cssExpand",
        "./css/var/isHidden",
+       "./css/var/swap",
        "./css/curCSS",
        "./css/adjustCSS",
        "./css/defaultDisplay",
@@ -14,11 +15,10 @@ define([
        "./css/support",
 
        "./core/init",
-       "./css/swap",
        "./core/ready",
        "./selector" // contains
 ], function( jQuery, pnum, access, rmargin, rcssNum, rnumnonpx, cssExpand, isHidden,
-       curCSS, adjustCSS, defaultDisplay, addGetHookIf, support ) {
+       curCSS, swap, adjustCSS, defaultDisplay, addGetHookIf, support ) {
 
 var
        // BuildExclude
@@ -366,7 +366,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
                                // however, it must have a current display style that would benefit from this
                                return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
                                        elem.offsetWidth === 0 ?
-                                               jQuery.swap( elem, cssShow, function() {
+                                               swap( elem, cssShow, function() {
                                                        return getWidthOrHeight( elem, name, extra );
                                                }) :
                                                getWidthOrHeight( elem, name, extra );
@@ -440,7 +440,7 @@ if ( !support.opacity ) {
 jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
        function( elem, computed ) {
                if ( computed ) {
-                       return jQuery.swap( elem, { "display": "inline-block" },
+                       return swap( elem, { "display": "inline-block" },
                                curCSS, [ elem, "marginRight" ] );
                }
        }
diff --git a/src/css/swap.js b/src/css/swap.js
deleted file mode 100644 (file)
index ce16435..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-define([
-       "../core"
-], function( jQuery ) {
-
-// A method for quickly swapping in/out CSS properties to get correct calculations.
-jQuery.swap = function( elem, options, callback, args ) {
-       var ret, name,
-               old = {};
-
-       // Remember the old values, and insert the new ones
-       for ( name in options ) {
-               old[ name ] = elem.style[ name ];
-               elem.style[ name ] = options[ name ];
-       }
-
-       ret = callback.apply( elem, args || [] );
-
-       // Revert the old values
-       for ( name in options ) {
-               elem.style[ name ] = old[ name ];
-       }
-
-       return ret;
-};
-
-return jQuery.swap;
-
-});
diff --git a/src/css/var/swap.js b/src/css/var/swap.js
new file mode 100644 (file)
index 0000000..61351f1
--- /dev/null
@@ -0,0 +1,24 @@
+define(function() {
+
+// A method for quickly swapping in/out CSS properties to get correct calculations.
+return function swap( elem, options, callback, args ) {
+       var ret, name,
+               old = {};
+
+       // Remember the old values, and insert the new ones
+       for ( name in options ) {
+               old[ name ] = elem.style[ name ];
+               elem.style[ name ] = options[ name ];
+       }
+
+       ret = callback.apply( elem, args || [] );
+
+       // Revert the old values
+       for ( name in options ) {
+               elem.style[ name ] = old[ name ];
+       }
+
+       return ret;
+};
+
+});