On Jul 31, 4:19 pm, kangax wrote:
... . It appears, though, that the need
for "isElement" exists.
How does that appear? It appears that there is a desire and that the
desire is being serviced but nothing has yet suggested a need.
The goal is to implement its behavior in a
most intuitive and generalized way.
Pre-supposing the existence of a need might suggest a goal along those
lines, but without first establishing a need pursuing that goal might
be effort wasted.
And why 'most intuitive' or 'most generalised'? If a function/method
is just going to return true or false and third parties, are going to
trust that it does that in the way that its documentation says it
will, then it really doesn't matter that much how unintuitive the code
it contains may be.
While no real situations are truly general so striving to create the
'most general' anything probably is not that good an idea when
'sufficiently general' could be a knowable state and 'most general' an
unachievable (and possibly undesirable) ideal.
Consider the Core DOM's namespace qualified methods. Even in something
as theoretically general as a general-purpose HTML DOM library it will
not be necessary to use namespace qualified Node/Element methods. And
the - isElement - code shown here is certainly no grantee that the
object for which a - true - result is achieved has those methods (as
IE will give true results for objects implementing the Element
interface but does not provide the namespace qualified methods in its
HTML DOM). That is fine because nobody is gong to need to use
namespace qualified methods in an HTML DOM.
However, the more general situation of trying to write a general-
purpose library for both HTML and XHTML DOMs necessitates the use of
the namespace qualified methods in the XHTML DOM, but the - isElement
- code here does not give any relationship between its true results
and the objects having the necessary methods. More general code might
be indicated for that more general situation, but as that situation is
extremely uncommon it probably does not matter if any - isElement -
code is less than the 'most general'.