jquery core: closes #2968. Simplified isFunction, dropping support for DOM methods and functions like alert() on IE.

This commit is contained in:
Ariel Flesler 2008-07-23 16:18:05 +00:00
parent 43c4b64f32
commit 69212c501f
2 changed files with 8 additions and 5 deletions

View file

@ -613,9 +613,10 @@ jQuery.extend({
}, },
// See test/unit/core.js for details concerning this function. // 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 ) { isFunction: function( fn ) {
return !!fn && typeof fn != "string" && !fn.nodeName && return fn instanceof Function;
fn.constructor != Array && /^[\s[]?function/.test( fn + "" );
}, },
// check if an element is in a (or is an) XML document // check if an element is in a (or is an) XML document

View file

@ -107,7 +107,7 @@ test("noConflict", function() {
}); });
test("isFunction", function() { test("isFunction", function() {
expect(21); expect(19);
// Make sure that false values return false // Make sure that false values return false
ok( !jQuery.isFunction(), "No Value" ); ok( !jQuery.isFunction(), "No Value" );
@ -145,7 +145,8 @@ test("isFunction", function() {
ok( !jQuery.isFunction(obj), "Object Element" ); ok( !jQuery.isFunction(obj), "Object Element" );
// IE says this is an object // 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; var nodes = document.body.childNodes;
@ -162,7 +163,8 @@ test("isFunction", function() {
document.body.appendChild( input ); document.body.appendChild( input );
// IE says this is an object // 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 ); document.body.removeChild( input );