From 69212c501f8875b4650847053cc41eaa470e5848 Mon Sep 17 00:00:00 2001 From: Ariel Flesler Date: Wed, 23 Jul 2008 16:18:05 +0000 Subject: [PATCH] jquery core: closes #2968. Simplified isFunction, dropping support for DOM methods and functions like alert() on IE. --- src/core.js | 5 +++-- test/unit/core.js | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/core.js b/src/core.js index 7db0a8c..c095f74 100644 --- a/src/core.js +++ b/src/core.js @@ -613,9 +613,10 @@ jQuery.extend({ }, // See test/unit/core.js for details concerning this function. + // Since 1.3 DOM methods and function like alert + // aren't supported. They return false on IE (#2968). isFunction: function( fn ) { - return !!fn && typeof fn != "string" && !fn.nodeName && - fn.constructor != Array && /^[\s[]?function/.test( fn + "" ); + return fn instanceof Function; }, // check if an element is in a (or is an) XML document diff --git a/test/unit/core.js b/test/unit/core.js index 71b1246..864f77a 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -107,7 +107,7 @@ test("noConflict", function() { }); test("isFunction", function() { - expect(21); + expect(19); // Make sure that false values return false ok( !jQuery.isFunction(), "No Value" ); @@ -145,7 +145,8 @@ test("isFunction", function() { ok( !jQuery.isFunction(obj), "Object Element" ); // IE says this is an object - ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" ); + // Since 1.3, this isn't supported (#2968) + //ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" ); var nodes = document.body.childNodes; @@ -162,7 +163,8 @@ test("isFunction", function() { document.body.appendChild( input ); // IE says this is an object - ok( jQuery.isFunction(input.focus), "A default function property" ); + // Since 1.3, this isn't supported (#2968) + //ok( jQuery.isFunction(input.focus), "A default function property" ); document.body.removeChild( input ); -- 1.7.10.4