Fix #12191. jQuery.type should return "error" for Error objects.

This commit is contained in:
Dave Methvin 2012-11-24 17:22:14 -05:00
parent 78c1560065
commit 67df705bf5
2 changed files with 3 additions and 2 deletions

View File

@ -902,7 +902,7 @@ jQuery.ready.promise = function( obj ) {
}; };
// Populate the class2type map // 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(); class2type[ "[object " + name + "]" ] = name.toLowerCase();
}); });

View File

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