Skip to content

Commit d557e06

Browse files
committed
Merge pull request #437 from alancutter/deprecatedTesting
Deprecate invalid timing inputs instead of throwing TypeErrors immediately
2 parents 1871bfe + b83173b commit d557e06

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/deprecation.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
var silenced = {};
1818

1919
shared.isDeprecated = function(feature, date, advice, plural) {
20+
if (WEB_ANIMATIONS_TESTING) {
21+
return true;
22+
}
23+
2024
var auxVerb = plural ? 'are' : 'is';
2125
var today = new Date();
2226
var expiry = new Date(date);

src/timing-utilities.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
this._easingFunction = linear;
4343
}
4444

45+
function isInvalidTimingDeprecated() {
46+
return shared.isDeprecated('Invalid timing inputs', '2016-03-02', 'TypeError exceptions will be thrown instead.', true);
47+
}
48+
4549
AnimationEffectTiming.prototype = {
4650
_setMember: function(member, value) {
4751
this['_' + member] = value;
@@ -76,7 +80,7 @@
7680
return this._fill;
7781
},
7882
set iterationStart(value) {
79-
if (isNaN(value) || value < 0) {
83+
if ((isNaN(value) || value < 0) && isInvalidTimingDeprecated()) {
8084
throw new TypeError('iterationStart must be a non-negative number, received: ' + timing.iterationStart);
8185
}
8286
this._setMember('iterationStart', value);
@@ -85,7 +89,7 @@
8589
return this._iterationStart;
8690
},
8791
set duration(value) {
88-
if (value != 'auto' && (isNaN(value) || value < 0)) {
92+
if (value != 'auto' && (isNaN(value) || value < 0) && isInvalidTimingDeprecated()) {
8993
throw new TypeError('duration must be non-negative or auto, received: ' + value);
9094
}
9195
this._setMember('duration', value);
@@ -107,7 +111,7 @@
107111
return this._easing;
108112
},
109113
set iterations(value) {
110-
if (isNaN(value) || value < 0) {
114+
if ((isNaN(value) || value < 0) && isInvalidTimingDeprecated()) {
111115
throw new TypeError('iterations must be non-negative, received: ' + value);
112116
}
113117
this._setMember('iterations', value);
@@ -228,7 +232,7 @@
228232
styleForCleaning.animationTimingFunction = easing;
229233
var validatedEasing = styleForCleaning.animationTimingFunction;
230234

231-
if (validatedEasing == '') {
235+
if (validatedEasing == '' && isInvalidTimingDeprecated()) {
232236
throw new TypeError(easing + ' is not a valid value for easing');
233237
}
234238

0 commit comments

Comments
 (0)