Skip to content

Commit a46e4b9

Browse files
committed
Effects: Warn and fill jQuery.fx.interval
Fixes #215 Closes #216
1 parent 6041d46 commit a46e4b9

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/effects.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,12 @@ jQuery.Tween.prototype.run = function( percent ) {
1616

1717
oldTweenRun.apply( this, arguments );
1818
};
19+
20+
jQuery.fx.interval = jQuery.fx.interval || 13;
21+
22+
// Support: IE9, Android <=4.4
23+
// Avoid false positives on browsers that lack rAF
24+
if ( window.requestAnimationFrame ) {
25+
migrateWarnProp( jQuery.fx, "interval", jQuery.fx.interval,
26+
"jQuery.fx.interval is deprecated" );
27+
}

src/migrate.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ function migrateWarnProp( obj, prop, value, msg ) {
6464
get: function() {
6565
migrateWarn( msg );
6666
return value;
67+
},
68+
set: function( newValue ) {
69+
migrateWarn( msg );
70+
value = newValue;
6771
}
6872
} );
6973
}

test/effects.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,39 @@ QUnit.test( "jQuery.easing", function( assert ) {
1818
div.animate( { width: 20 }, 10, "test" );
1919
} );
2020
} );
21+
22+
// If the browser has requestAnimationFrame, jQuery won't touch fx.interval
23+
QUnit.test( "jQuery.fx.interval - no warning on animations", function( assert ) {
24+
assert.expect( 1 );
25+
26+
var start = assert.async();
27+
28+
// Can't use expectNoWarning since this is async
29+
jQuery.migrateReset();
30+
jQuery( "<div />" )
31+
.appendTo( "#qunit-fixture" )
32+
.animate( { opacity: 0.5 }, 50, function() {
33+
assert.equal( jQuery.migrateWarnings.length, 0, "no warning" );
34+
start();
35+
} );
36+
} );
37+
38+
// Only rAF browsers implement the interval warning
39+
QUnit.test( "jQuery.fx.interval - user change", function( assert ) {
40+
assert.expect( 3 );
41+
42+
var oldInterval,
43+
warner = window.requestAnimationFrame ? expectWarning : expectNoWarning;
44+
45+
assert.ok( true, "requestAnimationFrame is " +
46+
( window.requestAnimationFrame ? "present" : "absent" ) );
47+
warner( "read fx.interval", function() {
48+
oldInterval = jQuery.fx.interval;
49+
} );
50+
warner( "write fx.interval", function() {
51+
jQuery.fx.interval = 13;
52+
} );
53+
54+
jQuery.fx.interval = oldInterval;
55+
} );
56+

warnings.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ This is _not_ a warning, but a console log message the plugin shows when it firs
1919

2020
**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.
2121

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

2424
### JQMIGRATE: Migrate plugin loaded multiple times
2525

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

28-
**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.
28+
**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.
2929

3030
### JQMIGRATE: Attribute selector with '#' must be quoted
3131
### 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
6767

6868
**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.
6969

70+
### JQMIGRATE: jQuery.fx.interval is deprecated
71+
72+
**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.
73+
74+
**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.
75+
7076
### JQMIGRATE: jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()
7177

7278
**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.

0 commit comments

Comments
 (0)