Skip to content

Commit b6b0ea4

Browse files
committed
Effects: restore and warn on arity of jQuery.easing functions
Uses Function#bind, so it has obvious downside, but it seems acceptable for migrate plugin Fixes #111
1 parent b9116c5 commit b6b0ea4

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/effects.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var old = jQuery.Tween.prototype.run;
2+
3+
jQuery.Tween.prototype.run = function( percent ) {
4+
if ( jQuery.easing[ this.easing ].length > 1 ) {
5+
migrateWarn(
6+
"easing function " +
7+
"\"jQuery.easing." + this.easing.toString() +
8+
"\" should use only first argument"
9+
);
10+
}
11+
12+
jQuery.easing[ this.easing ] = jQuery.easing[ this.easing ].bind(
13+
jQuery.easing,
14+
percent, this.options.duration * percent, 0, 1, this.options.duration
15+
);
16+
17+
old.apply( this, arguments );
18+
}

test/effects.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module( "effects" );
2+
3+
QUnit.test( "jQuery.easing", function( assert ) {
4+
assert.expect( 5 );
5+
6+
jQuery.easing.test = function( p, n, firstNum, diff ) {
7+
assert.notEqual( p, undefined );
8+
assert.notEqual( n, undefined );
9+
assert.notEqual( firstNum, undefined );
10+
assert.notEqual( diff, undefined );
11+
};
12+
13+
var div = jQuery( "<div>test</div>" );
14+
15+
div.appendTo( "#qunit-fixture" );
16+
17+
expectWarning( "easing", function() {
18+
div.animate({ width: 20 }, 10, "test" );
19+
});
20+
});

test/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<script src="event.js"></script>
4343
<script src="traversing.js"></script>
4444
<script src="deferred.js"></script>
45+
<script src="effects.js"></script>
4546
</head>
4647
<body>
4748
<div id="qunit"></div>

0 commit comments

Comments
 (0)