Bug 1489109 - Accept negative values in font editor if axis range allows it. r=gl

MozReview-Commit-ID: 7ABne1snpSW

Differential Revision: https://phabricator.services.mozilla.com/D5161

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Razvan Caliman 2018-09-06 16:58:51 +00:00
Родитель 96fe434cb7
Коммит 5de11b6599
1 изменённых файлов: 5 добавлений и 3 удалений

Просмотреть файл

@ -162,9 +162,12 @@ class FontPropertyValue extends PureComponent {
* Change event.
*/
onChange(e) {
// Regular expresion to check for positive floating point or integer numbers.
// Regular expresion to check for floating point or integer numbers. Accept negative
// numbers only if the min value is negative. Otherwise, expect positive numbers.
// Whitespace and non-digit characters are invalid (aside from a single dot).
const regex = /^[0-9]+(.[0-9]+)?$/;
const regex = (this.props.min && this.props.min < 0)
? /^-?[0-9]+(.[0-9]+)?$/
: /^[0-9]+(.[0-9]+)?$/;
let string = e.target.value.trim();
if (e.target.validity.badInput) {
@ -190,7 +193,6 @@ class FontPropertyValue extends PureComponent {
return;
}
// Catch any negative or irrational numbers.
if (!regex.test(string)) {
return;
}