Skip to content

Commit 4fc5ea1

Browse files
committed
Unit Tests & effects.scale: Fixing bugs in effects unit tests - Particularly IE, found a bug in scale.js in the meantime. Fixes #7395 - Size based effects are breaking unit tests in IE - also leaking a global var
1 parent 4f0f407 commit 4fc5ea1

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

tests/unit/effects/effects.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
.test {
3939
background: #000;
4040
border: 0;
41+
width: 100px;
42+
height: 100px;
4143
}
4244
.testAddBorder {
4345
border: 10px solid #000;
4446
}
47+
.testChildren,
4548
.testChangeBackground {
4649
background: #fff;
4750
}

tests/unit/effects/effects_core.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ asyncTest( "animateClass works with colors", function() {
7777
count = 0;
7878
expect(2);
7979
test.toggleClass("testChangeBackground", duration, function() {
80-
present( test.css("backgroundColor"), [ "#ffffff", "rgb(255, 255, 255)" ], "Color is final" );
80+
present( test.css("backgroundColor"), [ "#ffffff", "#fff", "rgb(255, 255, 255)" ], "Color is final" );
8181
start();
8282
});
8383
setTimeout(function() {
8484
var color = test.css("backgroundColor");
85-
notPresent( color, [ "#000000", "#ffffff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
85+
notPresent( color, [ "#000000", "#ffffff", "#000", "#fff", "rgb(0, 0, 0)", "rgb(255,255,255)" ],
8686
"Color is not endpoints in middle." );
8787
}, mid);
8888
});
@@ -92,19 +92,20 @@ asyncTest( "animateClass works with children", function() {
9292
h2 = test.find("h2");
9393

9494
expect(4);
95+
setTimeout(function() {
96+
notPresent( h2.css("fontSize"), ["10px","20px"], "Font size is neither endpoint when in middle.");
97+
}, mid);
9598
test.toggleClass("testChildren", { children: true, duration: duration, complete: function() {
9699
equal( h2.css("fontSize"), "20px", "Text size is final during complete");
97100
test.toggleClass("testChildren", duration, function() {
98101
equal( h2.css("fontSize"), "10px", "Text size revertted after class removed");
102+
99103
start();
100104
});
101105
setTimeout(function() {
102-
equal( h2.css("fontSize"), "20px", "Text size unchanged with children: undefined" );
106+
equal( h2.css("fontSize"), "20px", "Text size unchanged during animate with children: undefined" );
103107
}, mid);
104108
}});
105-
setTimeout(function() {
106-
notPresent( h2.css("fontSize"), ["10px","20px"], "Font size is neither endpoint when in middle.");
107-
}, mid);
108109
});
109110

110111
})(jQuery);

ui/jquery.effects.core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ $.extend( $.effects, {
451451
setTransition: function( element, list, factor, value ) {
452452
value = value || {};
453453
$.each( list, function(i, x){
454-
unit = element.cssUnit( x );
454+
var unit = element.cssUnit( x );
455455
if ( unit[ 0 ] > 0 ) value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
456456
});
457457
return value;

ui/jquery.effects.scale.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,15 @@ $.effects.effect.size = function( o ) {
115115
restore = o.restore || false,
116116
scale = o.scale || 'both',
117117
origin = o.origin,
118-
original = {
119-
height: el.height(),
120-
width: el.width()
121-
},
122-
baseline, factor;
118+
original, baseline, factor;
119+
120+
if ( mode === "show" ) {
121+
el.show();
122+
}
123+
original = {
124+
height: el.height(),
125+
width: el.width()
126+
};
123127

124128
el.from = o.from || original;
125129
el.to = o.to || original;
@@ -149,14 +153,14 @@ $.effects.effect.size = function( o ) {
149153
if ( scale == 'box' || scale == 'both' ) {
150154

151155
// Vertical props scaling
152-
if ( factor.from.y != factor.to.y ) {
156+
if ( factor.from.y !== factor.to.y ) {
153157
props = props.concat( vProps );
154158
el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
155159
el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
156160
};
157161

158162
// Horizontal props scaling
159-
if ( factor.from.x != factor.to.x ) {
163+
if ( factor.from.x !== factor.to.x ) {
160164
props = props.concat( hProps );
161165
el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
162166
el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
@@ -167,7 +171,7 @@ $.effects.effect.size = function( o ) {
167171
if ( scale == 'content' || scale == 'both' ) {
168172

169173
// Vertical props scaling
170-
if ( factor.from.y != factor.to.y ) {
174+
if ( factor.from.y !== factor.to.y ) {
171175
props = props.concat( cProps );
172176
el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
173177
el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );

0 commit comments

Comments
 (0)