24
24
var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
25
25
"borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor" ,
26
26
27
+ class2type = { } ,
28
+ toString = class2type . toString ,
29
+
27
30
// plusequals test for += 100 -= 100
28
31
rplusequals = / ^ ( [ \- + ] ) = \s * ( \d + \. ? \d * ) / ,
29
32
@@ -153,6 +156,22 @@ each( spaces, function( spaceName, space ) {
153
156
} ;
154
157
} ) ;
155
158
159
+ // Populate the class2type map
160
+ jQuery . each ( "Boolean Number String Function Array Date RegExp Object Error Symbol" . split ( " " ) ,
161
+ function ( i , name ) {
162
+ class2type [ "[object " + name + "]" ] = name . toLowerCase ( ) ;
163
+ } ) ;
164
+
165
+ function getType ( obj ) {
166
+ if ( obj == null ) {
167
+ return obj + "" ;
168
+ }
169
+
170
+ return typeof obj === "object" ?
171
+ class2type [ toString . call ( obj ) ] || "object" :
172
+ typeof obj ;
173
+ }
174
+
156
175
function clamp ( value , prop , allowEmpty ) {
157
176
var type = propTypes [ prop . type ] || { } ;
158
177
@@ -226,7 +245,7 @@ color.fn = jQuery.extend( color.prototype, {
226
245
}
227
246
228
247
var inst = this ,
229
- type = jQuery . type ( red ) ,
248
+ type = getType ( red ) ,
230
249
rgba = this . _rgba = [ ] ;
231
250
232
251
// more than 1 argument specified - assume ( red, green, blue, alpha )
@@ -518,7 +537,7 @@ each( spaces, function( spaceName, space ) {
518
537
}
519
538
520
539
var ret ,
521
- type = jQuery . type ( value ) ,
540
+ type = getType ( value ) ,
522
541
arr = ( type === "array" || type === "object" ) ? value : arguments ,
523
542
local = this [ cache ] . slice ( ) ;
524
543
@@ -548,7 +567,7 @@ each( spaces, function( spaceName, space ) {
548
567
}
549
568
color . fn [ key ] = function ( value ) {
550
569
var local , cur , match , fn ,
551
- vtype = jQuery . type ( value ) ;
570
+ vtype = getType ( value ) ;
552
571
553
572
if ( key === "alpha" ) {
554
573
fn = this . _hsla ? "hsla" : "rgba" ;
@@ -564,7 +583,7 @@ each( spaces, function( spaceName, space ) {
564
583
565
584
if ( vtype === "function" ) {
566
585
value = value . call ( this , cur ) ;
567
- vtype = jQuery . type ( value ) ;
586
+ vtype = getType ( value ) ;
568
587
}
569
588
if ( value == null && prop . empty ) {
570
589
return this ;
@@ -590,7 +609,7 @@ color.hook = function( hook ) {
590
609
set : function ( elem , value ) {
591
610
var parsed ;
592
611
593
- if ( value !== "transparent" && ( jQuery . type ( value ) !== "string" || ( parsed = stringParse ( value ) ) ) ) {
612
+ if ( value !== "transparent" && ( getType ( value ) !== "string" || ( parsed = stringParse ( value ) ) ) ) {
594
613
value = color ( parsed || value ) ;
595
614
value = value . toRgbaString ( ) ;
596
615
}
0 commit comments