Skip to content

Commit

Permalink
Effects: Remove jQuery.fx.interval
Browse files Browse the repository at this point in the history
`jQuery.fx.interval` has been deprecated since jQuery 3.0.0 but it has been
still used in jQuery code until this change. This commit removes the definition
and explicitly uses the `13` number in its place.

Closes gh-5017
  • Loading branch information
mgol committed Mar 1, 2022
1 parent af1cd6f commit 6c2c736
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 181 deletions.
3 changes: 1 addition & 2 deletions src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function schedule() {
if ( document.hidden === false && window.requestAnimationFrame ) {
window.requestAnimationFrame( schedule );
} else {
window.setTimeout( schedule, jQuery.fx.interval );
window.setTimeout( schedule, 13 );
}

jQuery.fx.tick();
Expand Down Expand Up @@ -663,7 +663,6 @@ jQuery.fx.timer = function( timer ) {
jQuery.fx.start();
};

jQuery.fx.interval = 13;
jQuery.fx.start = function() {
if ( inProgress ) {
return;
Expand Down
14 changes: 6 additions & 8 deletions test/unit/animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ if ( !jQuery.fx ) {
return;
}

var oldRaf = window.requestAnimationFrame,
var fxInterval = 13,
oldRaf = window.requestAnimationFrame,
defaultPrefilter = jQuery.Animation.prefilters[ 0 ],
defaultTweener = jQuery.Animation.tweeners[ "*" ][ 0 ],
startTime = 505877050;
Expand All @@ -15,17 +16,14 @@ QUnit.module( "animation", {
beforeEach: function() {
this.sandbox = sinon.createSandbox();
this.clock = this.sandbox.useFakeTimers( startTime );
this._oldInterval = jQuery.fx.interval;
window.requestAnimationFrame = null;
jQuery.fx.step = {};
jQuery.fx.interval = 10;
jQuery.Animation.prefilters = [ defaultPrefilter ];
jQuery.Animation.tweeners = { "*": [ defaultTweener ] };
},
afterEach: function() {
this.sandbox.restore();
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
window.requestAnimationFrame = oldRaf;
return moduleTeardown.apply( this, arguments );
}
Expand All @@ -36,7 +34,7 @@ QUnit.test( "Animation( subject, props, opts ) - shape", function( assert ) {

var subject = { test: 0 },
props = { test: 1 },
opts = { queue: "fx", duration: 100 },
opts = { queue: "fx", duration: fxInterval * 10 },
animation = jQuery.Animation( subject, props, opts );

assert.equal(
Expand All @@ -59,14 +57,14 @@ QUnit.test( "Animation( subject, props, opts ) - shape", function( assert ) {
assert.deepEqual( animation.props, props, ".props is a copy of the original" );

assert.deepEqual( animation.opts, {
duration: 100,
duration: fxInterval * 10,
queue: "fx",
specialEasing: { test: undefined },
easing: jQuery.easing._default
}, ".options is filled with default easing and specialEasing" );

assert.equal( animation.startTime, startTime, "startTime was set" );
assert.equal( animation.duration, 100, ".duration is set" );
assert.equal( animation.duration, fxInterval * 10, ".duration is set" );

assert.equal( animation.tweens.length, 1, ".tweens has one Tween" );
assert.equal( typeof animation.tweens[ 0 ].run, "function", "which has a .run function" );
Expand All @@ -85,7 +83,7 @@ QUnit.test( "Animation( subject, props, opts ) - shape", function( assert ) {
assert.equal( jQuery.timers[ 0 ].queue, opts.queue, "...with .queue" );

// Cleanup after ourselves by ticking to the end
this.clock.tick( 100 );
this.clock.tick( fxInterval * 10 );
} );

QUnit.test( "Animation.prefilter( fn ) - calls prefilter after defaultPrefilter",
Expand Down
Loading

0 comments on commit 6c2c736

Please sign in to comment.