Skip to content

Commit

Permalink
Fixes incorrect value validation for step attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
tiesont committed Nov 4, 2019
1 parent 8fd3e7d commit 48c079a
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ Bootbox **3.3.0** is the *last* release to support Bootstrap 2.2.x.

Much more dependency information can be found [on the Bootbox website](http://bootboxjs.com/getting-started.html#bootbox-dependencies).

## 5.3.2 (Latest Release)
## 5.3.3 (Latest Release)

- Adds Georgian (ka) locale.
- Fixes incorrect value validation for the `step` option when setting `inputType` to `number` for a prompt.

For a full list of releases and changes please see [the changelog](https://github.com/makeusabrew/bootbox/blob/master/CHANGELOG.md).

Expand Down
15 changes: 4 additions & 11 deletions bootbox.all.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! @preserve
* bootbox.js
* version: 5.3.2
* version: 5.3.3
* author: Nick Payne <[email protected]>
* license: MIT
* http://bootboxjs.com/
Expand Down Expand Up @@ -880,7 +880,7 @@
// @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates
if (options.inputType !== 'date') {
if (options.step) {
if (options.step === 'any' || (!isNaN(options.step) && parseInt(options.step) > 0)) {
if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) {
input.attr('step', options.step);
}
else {
Expand Down Expand Up @@ -1346,10 +1346,12 @@
}
else {
if (min !== undefined && isNaN(min)) {
minValid = false;
throw new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');
}

if (max !== undefined && isNaN(max)) {
maxValid = false;
throw new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.');
}
}
Expand All @@ -1374,15 +1376,6 @@
return /(\d{4})-(\d{2})-(\d{2})/.test(value);
}


// Register the default locale
exports.addLocale('en', {
OK: 'OK',
CANCEL: 'Cancel',
CONFIRM: 'OK'
});


// The Bootbox object
return exports;
}));
6 changes: 4 additions & 2 deletions bootbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! @preserve
* bootbox.js
* version: 5.3.2
* version: 5.3.3
* author: Nick Payne <[email protected]>
* license: MIT
* http://bootboxjs.com/
Expand Down Expand Up @@ -679,7 +679,7 @@
// @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Setting_maximum_and_minimum_dates
if (options.inputType !== 'date') {
if (options.step) {
if (options.step === 'any' || (!isNaN(options.step) && parseInt(options.step) > 0)) {
if (options.step === 'any' || (!isNaN(options.step) && parseFloat(options.step) > 0)) {
input.attr('step', options.step);
}
else {
Expand Down Expand Up @@ -1145,10 +1145,12 @@
}
else {
if (min !== undefined && isNaN(min)) {
minValid = false;
throw new Error('"min" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-min for more information.');
}

if (max !== undefined && isNaN(max)) {
maxValid = false;
throw new Error('"max" must be a valid number. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-max for more information.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion bootbox.locales.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! @preserve
* bootbox.locales.js
* version: 5.3.2
* version: 5.3.3
* author: Nick Payne <[email protected]>
* license: MIT
* http://bootboxjs.com/
Expand Down
4 changes: 2 additions & 2 deletions dist/bootbox.all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bootbox.locales.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/bootbox.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion header.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* bootbox.js 5.3.2
* bootbox.js 5.3.3
*
* http://bootboxjs.com/license.txt
*/
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bootbox",
"version": "5.3.2",
"version": "5.3.3",
"description": "Wrappers for JavaScript alert(), confirm(), prompt(), and other flexible dialogs using the Bootstrap framework",
"directories": {
"test": "tests"
Expand Down
41 changes: 38 additions & 3 deletions tests/prompt.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 48c079a

Please sign in to comment.