Skip to content

Effects: Warn and fill jQuery.fx.interval #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@ jQuery.Tween.prototype.run = function( percent ) {

oldTweenRun.apply( this, arguments );
};

jQuery.fx.interval = jQuery.fx.interval || 13;

// Support: IE9, Android <=4.4
// Avoid false positives on browsers that lack rAF
if ( window.requestAnimationFrame ) {
migrateWarnProp( jQuery.fx, "interval", jQuery.fx.interval,
"jQuery.fx.interval is deprecated" );
}
4 changes: 4 additions & 0 deletions src/migrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ function migrateWarnProp( obj, prop, value, msg ) {
get: function() {
migrateWarn( msg );
return value;
},
set: function( newValue ) {
migrateWarn( msg );
value = newValue;
}
} );
}
Expand Down
36 changes: 36 additions & 0 deletions test/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,39 @@ QUnit.test( "jQuery.easing", function( assert ) {
div.animate( { width: 20 }, 10, "test" );
} );
} );

// If the browser has requestAnimationFrame, jQuery won't touch fx.interval
QUnit.test( "jQuery.fx.interval - no warning on animations", function( assert ) {
assert.expect( 1 );

var start = assert.async();

// Can't use expectNoWarning since this is async
jQuery.migrateReset();
jQuery( "<div />" )
.appendTo( "#qunit-fixture" )
.animate( { opacity: 0.5 }, 50, function() {
assert.equal( jQuery.migrateWarnings.length, 0, "no warning" );
start();
} );
} );

// Only rAF browsers implement the interval warning
QUnit.test( "jQuery.fx.interval - user change", function( assert ) {
assert.expect( 3 );

var oldInterval,
warner = window.requestAnimationFrame ? expectWarning : expectNoWarning;

assert.ok( true, "requestAnimationFrame is " +
( window.requestAnimationFrame ? "present" : "absent" ) );
warner( "read fx.interval", function() {
oldInterval = jQuery.fx.interval;
} );
warner( "write fx.interval", function() {
jQuery.fx.interval = 13;
} );

jQuery.fx.interval = oldInterval;
} );

10 changes: 8 additions & 2 deletions warnings.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ This is _not_ a warning, but a console log message the plugin shows when it firs

**Cause:** The page does not have a version of jQuery installed, or is using a version of jQuery older than 3.0.0. The jQuery Migrate plugin is not intended to be used for those cases. Any messages that follow this one may not be accurate, or the page may not run properly at all.

**Solution:** See the [README](https://github.com/jquery/jquery-migrate/#readme) for more information on usage and upgrading from older versions.
**Solution:** See the [README](https://github.com/jquery/jquery-migrate/#readme) for more information on usage and upgrading from older versions.

### JQMIGRATE: Migrate plugin loaded multiple times

**Cause:** The plugin detected that some version of jQuery Migrate is already loaded. Loading multiple versions can cause unpredictable behavior.

**Solution:** Remove all but the latest version of the jQuery Migrate plugin. See the [README](https://github.com/jquery/jquery-migrate/#readme) for more information on usage and upgrading from older versions.
**Solution:** Remove all but the latest version of the jQuery Migrate plugin. See the [README](https://github.com/jquery/jquery-migrate/#readme) for more information on usage and upgrading from older versions.

### JQMIGRATE: Attribute selector with '#' must be quoted
### JQMIGRATE: Attribute selector with '#' was not fixed
Expand Down Expand Up @@ -67,6 +67,12 @@ This is _not_ a warning, but a console log message the plugin shows when it firs

**Solution**: In most cases it is sufficient to change all occurrences of `.pipe()` to `.then()`. Ensure that you aren't relying on context/state propagation (e.g., using `this`) or synchronous callback invocation, which were dropped from `.then()` for Promises/A+ interoperability as of jQuery 3.0.

### JQMIGRATE: jQuery.fx.interval is deprecated

**Cause**: As of jQuery 3.0 the `jQuery.fx.interval` property can be used to change the animation interval _only_ on browsers that do not support the `window.requestAnimationFrame()` method. That is currently only Internet Explorer 9 and the Android Browser. Once support is dropped for these browsers, the property will serve no purpose and it will be removed.

**Solution**: Find and remove code that changes or uses `jQuery.fx.interval`. If the value is being used by code in your page or a plugin, the code may be making assumptions that are no longer valid. The default value of `jQuery.fx.interval` is `13` (milliseconds), which could be used instead of accessing this property.

### JQMIGRATE: jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()

**Cause**: The `.andSelf()` method has been renamed to `.addBack()` as of jQuery 1.9 to better reflect its purpose of adding back the previous set of results. The old alias was removed in jQuery 3.0.
Expand Down