Skip to content

Commit

Permalink
Avoid Number.isNaN
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanhamley committed Aug 9, 2019
1 parent add9a4d commit 4c078d9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/style-spec/util/get_type.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

export default function getType(val) {
if (Number.isNaN(val)) {
return 'NaN';
} else if (val instanceof Number) {
if (val instanceof Number) {
return 'number';
} else if (val instanceof String) {
return 'string';
Expand Down
6 changes: 5 additions & 1 deletion src/style-spec/validate/validate_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export default function validateNumber(options) {
const key = options.key;
const value = options.value;
const valueSpec = options.valueSpec;
const type = getType(value);
let type = getType(value);

if (type === 'number' && value !== value) {
type = 'NaN';
}

if (type !== 'number') {
return [new ValidationError(key, value, `number expected, ${type} found`)];
Expand Down

0 comments on commit 4c078d9

Please sign in to comment.