Skip to content

Commit 02a9d9f

Browse files
mgoltimmywil
authored andcommitted
CSS: Don't expose jQuery.swap
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
1 parent 345c95a commit 02a9d9f

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/css.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ define([
77
"./css/var/rnumnonpx",
88
"./css/var/cssExpand",
99
"./css/var/isHidden",
10+
"./css/var/swap",
1011
"./css/curCSS",
1112
"./css/adjustCSS",
1213
"./css/defaultDisplay",
1314
"./css/addGetHookIf",
1415
"./css/support",
1516

1617
"./core/init",
17-
"./css/swap",
1818
"./core/ready",
1919
"./selector" // contains
2020
], function( jQuery, pnum, access, rmargin, rcssNum, rnumnonpx, cssExpand, isHidden,
21-
curCSS, adjustCSS, defaultDisplay, addGetHookIf, support ) {
21+
curCSS, swap, adjustCSS, defaultDisplay, addGetHookIf, support ) {
2222

2323
var
2424
// BuildExclude
@@ -366,7 +366,7 @@ jQuery.each([ "height", "width" ], function( i, name ) {
366366
// however, it must have a current display style that would benefit from this
367367
return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
368368
elem.offsetWidth === 0 ?
369-
jQuery.swap( elem, cssShow, function() {
369+
swap( elem, cssShow, function() {
370370
return getWidthOrHeight( elem, name, extra );
371371
}) :
372372
getWidthOrHeight( elem, name, extra );
@@ -440,7 +440,7 @@ if ( !support.opacity ) {
440440
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
441441
function( elem, computed ) {
442442
if ( computed ) {
443-
return jQuery.swap( elem, { "display": "inline-block" },
443+
return swap( elem, { "display": "inline-block" },
444444
curCSS, [ elem, "marginRight" ] );
445445
}
446446
}

src/css/swap.js renamed to src/css/var/swap.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
define([
2-
"../core"
3-
], function( jQuery ) {
1+
define(function() {
42

53
// A method for quickly swapping in/out CSS properties to get correct calculations.
6-
jQuery.swap = function( elem, options, callback, args ) {
4+
return function swap( elem, options, callback, args ) {
75
var ret, name,
86
old = {};
97

@@ -23,6 +21,4 @@ jQuery.swap = function( elem, options, callback, args ) {
2321
return ret;
2422
};
2523

26-
return jQuery.swap;
27-
2824
});

0 commit comments

Comments
 (0)