Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.
This repository was archived by the owner on Jul 29, 2019. It is now read-only.

Incompatibility with datejs; mis-use of Date.parse #2490

@jimmed

Description

@jimmed

See first: abritinthebay/datejs#261

Suffice to say, I'm working on a large legacy application, which makes use of datejs's Date.parse extensions.

When rendering a Vis.js Timeline, rendering RangeItems makes use of utils.convert to coerce the start/end of the range to a number. However, when re-rendering, this coercion is repeated, passing an integer into utils.convert again.

When this happens, it passes a number to Date.parse, which is not officially supported by the ES5 spec. While the native version of this method in IE/FF/Chrome seems to handle this case, it's not something that should be relied upon, and accordingly using datejs's overloaded version of Date.parse causes errors, as it expects a string input.

in utils.convert

      if (!isNaN(Date.parse(object))) {
        return moment(object).valueOf();
      } else {
        return Number(object.valueOf());
      }

I originally assumed that the issue was with datejs, but as its author pointed out, Vis is misusing Date.parse.

I'm going to work on a fix that causes the minimum damage, but I'd love to hear from you guys in terms of suggestions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions