Permalink
Browse files

fix(df): Number.isInteger helper

adds a helper function to either use native Number.isInteger or a fallback for browsers like IE11

fixes issue #213
  • Loading branch information...
zewa666 committed Apr 26, 2017
1 parent b55bf0e commit 8bb1a87ceee79b4b50d1343c230263d3b3f87607
Showing with 8 additions and 1 deletion.
  1. +2 −1 src/df.js
  2. +6 −0 src/utils.js
View
@@ -2,6 +2,7 @@ import * as LogManager from 'aurelia-logging';
import {I18N} from './i18n';
import { SignalBindingBehavior } from 'aurelia-templating-resources';
import { ValueConverter } from 'aurelia-binding';
+import { isInteger } from './utils';
export class DfValueConverter {
static inject() { return [I18N]; }
@@ -26,7 +27,7 @@ export class DfValueConverter {
df = this.service.df(dfOrOptions, locale || this.service.getLocale());
}
- if (typeof value === 'string' && isNaN(value) && !Number.isInteger(value)) {
+ if (typeof value === 'string' && isNaN(value) && !isInteger(value)) {
value = new Date(value);
}
View
@@ -8,6 +8,12 @@ export let extend = (destination, source) => {
return destination;
};
+export const isInteger = Number.isInteger || function(value) {
+ return typeof value === 'number' &&
+ isFinite(value) &&
+ Math.floor(value) === value;
+};
+
export let assignObjectToKeys = (root, obj) => {
if (obj === undefined || obj === null) {
return obj;

0 comments on commit 8bb1a87

Please sign in to comment.