From 67df705bf5205fa075ba6ceee2d7fd4763894a16 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Sat, 24 Nov 2012 17:22:14 -0500 Subject: [PATCH] Fix #12191. jQuery.type should return "error" for Error objects. --- src/core.js | 2 +- test/unit/core.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 19246d1d3..9c4988869 100644 --- a/src/core.js +++ b/src/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(); }); diff --git a/test/unit/core.js b/test/unit/core.js index 14268d8c8..603368b9e 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -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.39.5