Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to using isNaN instead of RegExp for data-.
- Loading branch information
Showing
1 changed file
with
1 addition
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 comment
on commit 8ebb9b2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lint complains of unescaped curly braces in regexp in line: rbrace = /^(?:{.*}|\[.*\])$/;
.
Should be: rbrace = /^(?:\{.*\}|\[.*\])$/;
A small problem with
isNaN
and strings is that the Numeric String Grammar used by the internalToNumber
operation -whichisNaN
also uses- when applied on string values considers that a string which is empty or contains only whitespace characters is converted to0
.Therefore
isNaN("") == false
andisNaN(" ") == false
, and that can give a problem when adata-*
attribute contains such empty string, it will be detected as if it were a number, butparseFloat
will actually produceNaN
.I've posted an example with a recent build.