Re: isElement - determining if an object is an element
- From: "Aaron Gray" <ang.usenet@xxxxxxxxx>
- Date: Wed, 30 Jul 2008 15:33:17 +0100
"Henry" <rcornford@xxxxxxxxxxxxxx> wrote in message
news:35321f53-d3d9-4908-ab4a-7a26b27ea6d5@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Jul 30, 2:46 pm, Aaron Gray wrote:
<snip>
function isElement( o)<snip>
{
if (!isIE)
return o instanceof Element
else
return o && o.nodeType == 1 && o.tagName != undefined
}
Why branch for this? If the second test is ever good enough it is
always good enough.
Because I would like to use "conforming" browser traits, not that this is
actually one, but it should have been in my view. I take your point. But the
first test is faster and more accurate and runs on more browsers.
Exact equality (===) with 1 would be more precise than type-converting
equality and reduce the possible false positives.
Yes forgot to change that. Thanks,
But overall what it the point? If you inferred from a true result from
a call to your - isElement - method that the object implemented the
whole W3C Core DOM (Level 1 or 2) Element interface you would be wrong
in a number of cases. It would make more sense to decide what features
you wanted from such an element and test for those alone on a basis
driven by need.
Basically my library widget constructors either take a DOM structure,
normally the enclosing DIV (which is what I was wanting to test for) or a
JSON like object which describes the object, directly (or over AJAX).
Thanks for the feedback,
Aaron
.
- Follow-Ups:
- Re: isElement - determining if an object is an element
- From: Henry
- Re: isElement - determining if an object is an element
- From: Aaron Gray
- Re: isElement - determining if an object is an element
- References:
- isElement - determining if an object is an element
- From: Aaron Gray
- Re: isElement - determining if an object is an element
- From: Henry
- isElement - determining if an object is an element
- Prev by Date: Re: How to get rid of maniacs like Kamau Kambon? Filtersettings?
- Next by Date: Re: [OT] How to get rid of maniacs like Kamau Kambon? Filtersettings?
- Previous by thread: Re: isElement - determining if an object is an element
- Next by thread: Re: isElement - determining if an object is an element
- Index(es):
Relevant Pages
|