diff --git a/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js b/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js index 687239f8309..4896e107911 100644 --- a/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js +++ b/src/extensions/default/InlineTimingFunctionEditor/TimingFunctionUtils.js @@ -60,15 +60,15 @@ define(function (require, exports, module) { * If string is a number, then convert it. * * @param {string} str value parsed from page. - * @return { isNumber: boolean, value: number } + * @return { isNumber: boolean, value: ?number } */ function _convertToNumber(str) { - if (typeof (str) !== "string") { - return { isNumber: false }; + if (typeof str !== "string") { + return { isNumber: false, value: null }; } - var val = parseFloat(str, 10), - isNum = (typeof (val) === "number") && !isNaN(val) && + var val = parseFloat(+str, 10), + isNum = (typeof val === "number") && !isNaN(val) && (val !== Infinity) && (val !== -Infinity); return { diff --git a/src/extensions/default/InlineTimingFunctionEditor/unittests.js b/src/extensions/default/InlineTimingFunctionEditor/unittests.js index cc85c37a23b..c56764202a7 100644 --- a/src/extensions/default/InlineTimingFunctionEditor/unittests.js +++ b/src/extensions/default/InlineTimingFunctionEditor/unittests.js @@ -215,6 +215,9 @@ define(function (require, exports, module) { it("should correct cubic-bezier function with 5 parameters", function () { testInvalidBezier("cubic-bezier(0, 0, 1, 1, 1)", ["cubic-bezier(0, 0, 1, 1)", "0", "0", "1", "1"]); }); + it("should correct cubic-bezier function with trailing comma", function () { + testInvalidBezier("cubic-bezier(.42, 0, .58, .5,)", ["cubic-bezier(.42, 0, .58, .5)", ".42", "0", ".58", ".5"]); + }); // Real invalid cubic-beziers - they should NOT be corrected automatically it("should not match cubic-bezier function with invalid whitespace", function () {