Re: isElement - determining if an object is an element
- From: Henry <rcornford@xxxxxxxxxxxxxx>
- Date: Wed, 30 Jul 2008 07:03:41 -0700 (PDT)
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.
Exact equality (===) with 1 would be more precise than type-converting
equality and reduce the possible false positives.
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.
.
- Follow-Ups:
- 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
- isElement - determining if an object is an element
- Prev by Date: Re: [OT] How to get rid of maniacs like Kamau Kambon? Filtersettings?
- Next by Date: Re: eliminate results
- Previous by thread: isElement - determining if an object is an element
- Next by thread: Re: isElement - determining if an object is an element
- Index(es):
Relevant Pages
|