diff --git a/src/effects.js b/src/effects.js index 29ba1a69..6f48b750 100644 --- a/src/effects.js +++ b/src/effects.js @@ -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" ); +} diff --git a/src/migrate.js b/src/migrate.js index 3da5c005..3e30d07a 100644 --- a/src/migrate.js +++ b/src/migrate.js @@ -64,6 +64,10 @@ function migrateWarnProp( obj, prop, value, msg ) { get: function() { migrateWarn( msg ); return value; + }, + set: function( newValue ) { + migrateWarn( msg ); + value = newValue; } } ); } diff --git a/test/effects.js b/test/effects.js index 57ec7d5a..40f69953 100644 --- a/test/effects.js +++ b/test/effects.js @@ -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( "
" ) + .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; +} ); + diff --git a/warnings.md b/warnings.md index 5ca0cabe..ce989269 100644 --- a/warnings.md +++ b/warnings.md @@ -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 @@ -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.