aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorJason Bedard <jason+github@jbedard.ca>2018-01-14 00:46:20 -0800
committerTimmy Willison <4timmywil@gmail.com>2018-01-16 10:39:08 -0500
commit1ea092a54b00aa4d902f4e22ada3854d195d4a18 (patch)
tree705d445aa449743e06e6354bb3f746076700e31f /src/core
parent91fb18190e5ab9821e3c74b6aecbb5d197c6c5f6 (diff)
downloadjquery-1ea092a54b00aa4d902f4e22ada3854d195d4a18.tar.gz
jquery-1ea092a54b00aa4d902f4e22ada3854d195d4a18.zip
Core: deprecate jQuery.type
Fixes gh-3605 Close gh-3895
Diffstat (limited to 'src/core')
-rw-r--r--src/core/access.js5
-rw-r--r--src/core/toType.js20
2 files changed, 23 insertions, 2 deletions
diff --git a/src/core/access.js b/src/core/access.js
index 2e1eb4121..842c4a42b 100644
--- a/src/core/access.js
+++ b/src/core/access.js
@@ -1,7 +1,8 @@
define( [
"../core",
+ "../core/toType",
"../var/isFunction"
-], function( jQuery, isFunction ) {
+], function( jQuery, toType, isFunction ) {
"use strict";
@@ -13,7 +14,7 @@ var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
bulk = key == null;
// Sets many values
- if ( jQuery.type( key ) === "object" ) {
+ if ( toType( key ) === "object" ) {
chainable = true;
for ( i in key ) {
access( elems, fn, i, key[ i ], true, emptyGet, raw );
diff --git a/src/core/toType.js b/src/core/toType.js
new file mode 100644
index 000000000..c77ba95ad
--- /dev/null
+++ b/src/core/toType.js
@@ -0,0 +1,20 @@
+define( [
+ "../var/class2type",
+ "../var/toString"
+], function( class2type, toString ) {
+
+"use strict";
+
+function toType( obj ) {
+ if ( obj == null ) {
+ return obj + "";
+ }
+
+ // Support: Android <=2.3 only (functionish RegExp)
+ return typeof obj === "object" || typeof obj === "function" ?
+ class2type[ toString.call( obj ) ] || "object" :
+ typeof obj;
+}
+
+return toType;
+} );