Merge pull request #68 from subzey/feature/is-finite
Use native isFinite method to detect NaN and Infinitiesmaster
commit
6b92046ebd
|
@ -71,7 +71,6 @@ var has = "hasOwnProperty",
|
||||||
objectToString = Object.prototype.toString,
|
objectToString = Object.prototype.toString,
|
||||||
ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
|
ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
|
||||||
colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,
|
colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?%?)\s*\))\s*$/i,
|
||||||
isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1},
|
|
||||||
bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
|
bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
|
||||||
reURLValue = /^url\(#?([^)]+)\)$/,
|
reURLValue = /^url\(#?([^)]+)\)$/,
|
||||||
spaces = "\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",
|
spaces = "\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028\u2029",
|
||||||
|
@ -139,7 +138,7 @@ function getAttrs(el) {
|
||||||
function is(o, type) {
|
function is(o, type) {
|
||||||
type = Str.prototype.toLowerCase.call(type);
|
type = Str.prototype.toLowerCase.call(type);
|
||||||
if (type == "finite") {
|
if (type == "finite") {
|
||||||
return !isnan[has](+o);
|
return isFinite(o);
|
||||||
}
|
}
|
||||||
if (type == "array" &&
|
if (type == "array" &&
|
||||||
(o instanceof Array || Array.isArray && Array.isArray(o))) {
|
(o instanceof Array || Array.isArray && Array.isArray(o))) {
|
||||||
|
|
Loading…
Reference in New Issue