Skip to content
Permalink
Browse files
Fix #12191. jQuery.type should return "error" for Error objects.
  • Loading branch information
dmethvin committed Nov 24, 2012
1 parent 78c1560 commit 67df705bf5205fa075ba6ceee2d7fd4763894a16
Showing 2 changed files with 3 additions and 2 deletions.
@@ -902,7 +902,7 @@ jQuery.ready.promise = function( obj ) {
};

// Populate the class2type map
jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) {
class2type[ "[object " + name + "]" ] = name.toLowerCase();
});

@@ -250,7 +250,7 @@ test("trim", function() {
});

test("type", function() {
expect(23);
expect( 24 );

equal( jQuery.type(null), "null", "null" );
equal( jQuery.type(undefined), "undefined", "undefined" );
@@ -270,6 +270,7 @@ test("type", function() {
equal( jQuery.type(new Date()), "date", "Date" );
equal( jQuery.type(new Function("return;")), "function", "Function" );
equal( jQuery.type(function(){}), "function", "Function" );
equal( jQuery.type(new Error()), "error", "Error" );
equal( jQuery.type(window), "object", "Window" );
equal( jQuery.type(document), "object", "Document" );
equal( jQuery.type(document.body), "object", "Element" );

2 comments on commit 67df705

@rwaldron
Copy link
Member

@rwaldron rwaldron commented on 67df705 Nov 24, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I've held off on this is that there is more then one Error type constructors.

@rwaldron
Copy link
Member

@rwaldron rwaldron commented on 67df705 Nov 24, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neveind, the're all the same [[Class]], so this will cover those as well

Please sign in to comment.