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 with 3 additions and 2 deletions.
  1. +1 −1 src/core.js
  2. +2 −1 test/unit/core.js
@@ -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

This comment has been minimized.

Copy link
Member

rwaldron replied Nov 24, 2012

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

@rwaldron

This comment has been minimized.

Copy link
Member

rwaldron replied Nov 24, 2012

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

Please sign in to comment.
You can’t perform that action at this time.