Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 49e2004

Browse files
committed
Merge pull request #8910 from MarcelGerber/timing-function-editor-exception
Fix minor TimingFunction validation issue
2 parents 90c912e + 20c9e05 commit 49e2004

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ define(function (require, exports, module) {
6060
* If string is a number, then convert it.
6161
*
6262
* @param {string} str value parsed from page.
63-
* @return { isNumber: boolean, value: number }
63+
* @return { isNumber: boolean, value: ?number }
6464
*/
6565
function _convertToNumber(str) {
66-
if (typeof (str) !== "string") {
67-
return { isNumber: false };
66+
if (typeof str !== "string") {
67+
return { isNumber: false, value: null };
6868
}
6969

70-
var val = parseFloat(str, 10),
71-
isNum = (typeof (val) === "number") && !isNaN(val) &&
70+
var val = parseFloat(+str, 10),
71+
isNum = (typeof val === "number") && !isNaN(val) &&
7272
(val !== Infinity) && (val !== -Infinity);
7373

7474
return {

src/extensions/default/InlineTimingFunctionEditor/unittests.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ define(function (require, exports, module) {
215215
it("should correct cubic-bezier function with 5 parameters", function () {
216216
testInvalidBezier("cubic-bezier(0, 0, 1, 1, 1)", ["cubic-bezier(0, 0, 1, 1)", "0", "0", "1", "1"]);
217217
});
218+
it("should correct cubic-bezier function with trailing comma", function () {
219+
testInvalidBezier("cubic-bezier(.42, 0, .58, .5,)", ["cubic-bezier(.42, 0, .58, .5)", ".42", "0", ".58", ".5"]);
220+
});
218221

219222
// Real invalid cubic-beziers - they should NOT be corrected automatically
220223
it("should not match cubic-bezier function with invalid whitespace", function () {

0 commit comments

Comments
 (0)