aboutsummaryrefslogtreecommitdiffstats
path: root/src/deprecated.js
diff options
context:
space:
mode:
authorJason Bedard <jason+github@jbedard.ca>2017-12-12 21:51:49 -0800
committerJason Bedard <jason+github@jbedard.ca>2018-01-15 20:50:02 -0800
commitc4494d4abc84d368d6597889ab45fc07466f8f26 (patch)
treeef34afb4d08cbd9dcf8ea7fc65060aeddc6b322c /src/deprecated.js
parentd7237896c79a5a10d85fcdec199c5657a469a92b (diff)
downloadjquery-c4494d4abc84d368d6597889ab45fc07466f8f26.tar.gz
jquery-c4494d4abc84d368d6597889ab45fc07466f8f26.zip
Core: deprecate jQuery.isNumeric
Fixes gh-2960 Closes gh-3888
Diffstat (limited to 'src/deprecated.js')
-rw-r--r--src/deprecated.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/deprecated.js b/src/deprecated.js
index 0982f3a94..f1b7db7c6 100644
--- a/src/deprecated.js
+++ b/src/deprecated.js
@@ -79,4 +79,18 @@ jQuery.camelCase = camelCase;
jQuery.now = Date.now;
+jQuery.isNumeric = function( obj ) {
+
+ // As of jQuery 3.0, isNumeric is limited to
+ // strings and numbers (primitives or objects)
+ // that can be coerced to finite numbers (gh-2662)
+ var type = jQuery.type( obj );
+ return ( type === "number" || type === "string" ) &&
+
+ // parseFloat NaNs numeric-cast false positives ("")
+ // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
+ // subtraction forces infinities to NaN
+ !isNaN( obj - parseFloat( obj ) );
+};
+
} );