Due to M$'s stupidity in not making DOMElements first class citizens the
following will not work :-
function isElement( o)
{
return o instanceof Element
}
It works for FF, Opera and Safari.
What prototype does is this :-
isElement: function(object ) {
return object && object.nodeType == 1
}
My version used Browser sniffing :-
function isElement( o)
{
if (!isIE)
return o instanceof Element
else
return o && o.nodeType == 1 && o.tagName != undefined
}
Test case :-
The actual 'isIE' test code is not the best but is used for brevity.
Any crevats, problems or enhancements most welcome.
Thanks,
Aaron
following will not work :-
function isElement( o)
{
return o instanceof Element
}
It works for FF, Opera and Safari.
What prototype does is this :-
isElement: function(object ) {
return object && object.nodeType == 1
}
My version used Browser sniffing :-
function isElement( o)
{
if (!isIE)
return o instanceof Element
else
return o && o.nodeType == 1 && o.tagName != undefined
}
Test case :-
The actual 'isIE' test code is not the best but is used for brevity.
Any crevats, problems or enhancements most welcome.
Thanks,
Aaron
Comment