settings_org: Convert to number before parseFloat in parse_time_limit.

We now first convert the element value to number using "Number()"
function and then call parseFloat in parse_time_limit function.

If we do not do so and the input element contains something like
"24a", it will be converted to 24 after parseFloat and will result
in an unexpected behavior where the save-discard widget will not
appear if the custom value input is changed from "24" to "24a",
since the value is considered as same as before.

But now "24a" will return NaN and save-discard widget will
appear with save button disabled.
This commit is contained in:
Sahil Batra 2022-09-23 16:00:28 +05:30 committed by Tim Abbott
parent 711536f53a
commit eba390c6b2
1 changed files with 1 additions and 1 deletions

View File

@ -957,7 +957,7 @@ export function register_save_discard_widget_handlers(
}); });
parse_time_limit = function parse_time_limit($elem) { parse_time_limit = function parse_time_limit($elem) {
return Math.floor(Number.parseFloat($elem.val(), 10).toFixed(1) * 60); return Math.floor(Number.parseFloat(Number($elem.val()), 10).toFixed(1) * 60);
}; };
function get_complete_data_for_subsection(subsection) { function get_complete_data_for_subsection(subsection) {