On May 29, 6:42 pm, Diego Perini <[email protected]> wrote:
> Nathan,
> the "querySelectorAll" method exists also on IE 8 in Standard Mode.
>
> In all IE versions < 9 there are problem with the "Universal selector"
> since their API methods returns text nodes included in the result set.
> This is not only a problem with "querySelectorAll", in fact on IE < 9
> also "getElementsByTagName" has the same problems with text nodes.
>
> There are several other bugs in IE < 9 related to elements selection
> API. The baseline for IE is that after retrieving the NodeList one
> need to go through it members discarding text nodes, comments and
> invalid elements.
>
> The conditional I prefer to use to filter appropriate nodes from the list is:
>
> if (element.nodeName > '@') {
> .... // it is an Element node
That makes an assumption that all nodes with a nodeNames starting with
a character after @ are elements (or at least are nodes implementing
interface Element). However, the above will include nodes that
implement interfaces DocumentType, Entity, EntityReference, Notation
and ProcessingInstruction.
Is that what you want?
> }
>
> also the standard one is:
>
> if (element.nodeType == 1) {
> .... // it is an Element node
> }
If the intention is to filter for elements, then a test that explicity
tests for elements is prefereable to one that doesn't.
> I prefer the first since it also helps discard fake "closed tags"
> elements for non recognized HTML5 elements, for example:
>
> <abbr>NYC</abbr>
>
> could be recognized as two elements in some IE version <= 8, the first
> is the open tag "abbr", the second is the close tag "/abbr" which
> tagName/nodeName starts with a slash.
ABBR nodes are dysfunctional in IE < 7 and require special treatment.
Simply discarding the closing tag "element" is only part of the job.
--
Rob
--
To view archived discussions from the original JSMentors Mailman list:
http://www.mail-archive.com/[email protected]/
To search via a non-Google archive, visit here:
http://www.mail-archive.com/[email protected]/
To unsubscribe from this group, send email to
[email protected]