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
    }

also the standard one is:

    if (element.nodeType == 1) {
      .... // it is an Element node
    }

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.

The only selector string failing in your tests is the ".1st-p" which
correctly fails since the class name does not correspond to a valid
identifier.


--
Diego



On Sun, May 29, 2011 at 7:34 AM, Nathan Sweet <[email protected]> wrote:
>>>Whats the difference in Chrome, FF? nodelist is non-live in all of them.
> When I said unlike the others I meant the other IE versions, not the other
> browsers, my bad :
> It's kind of a moot point anyways, if it was implemented in <IE9 then it
> might have been implemented correctly. What I was referring to is that in
> <IE9 a lot of the selectors return nodelists that include intermittent text
> nodes for the empty spaces, whereas other browsers don't do that. I was
> referring to this particular quirk in <IE9, which prevents
> Array.prototype.slice.call from being cross-browser friendly for node lists
> for certain selector methods. Someone once told me that some libraries
> remove all the white space between elements, but I don't actually see how
> that could help as a spaced out innerHTML assignment could easily foul it
> up.
>
> On Sat, May 28, 2011 at 10:14 PM, Andrew Dodson <[email protected]>
> wrote:
>>
>> Isn't that what its supposed
>> to http://www.w3.org/TR/selectors-api/#nodeselector
>> Whats the difference in Chrome, FF? nodelist is non-live in all of them.
>>
>>
>>
>> On Sat, May 28, 2011 at 7:58 PM, Nathan Sweet <[email protected]>
>> wrote:
>>>
>>> I meant <IE9, IE9 also only returns elements in its nodelists, unlike the
>>> others.
>>>
>>> On Sat, May 28, 2011 at 7:54 PM, Andrew Dodson
>>> <[email protected]> wrote:
>>>>
>>>> querySelectorAll is enabled in IE9, checkout "ie9 testdrive".
>>>>
>>>> On 28 May 2011 19:50, "nathanJsweet" <[email protected]> wrote:
>>>>
>>>> So I've been messing around with querySelectorAll. I've published
>>>> a blog post about it which can be found at "nathansweet.me/
>>>> queryselectorall",
>>>> though I'm not really plugging the post, which actually doesn't have
>>>> so
>>>> much information concerning the method as it does a link to a page
>>>> I've created that tests the method.
>>>>
>>>> I'm asking anybody in this group who is interested take a look
>>>> at this page (it can be found at "nathansweet.me/queryselectorall-
>>>> rundown")
>>>> and email me, respond to this post, or comment on the blog post any
>>>> other selector ideas they can come up with. My goal would be to come
>>>> up with an exhaustive list of selectors that I could then run through
>>>> a multitude of browsers (I would, of course, share the results). I've
>>>> already come up with some interesting failures that shouldn't be
>>>> occurring,
>>>> and I'm also interested to hear from people who've worked with the
>>>> method extensively.
>>>>
>>>> Also am I wrong in thinking that since querySelectorAll isn't
>>>> implemented in IE
>>>> that it will always return only elements? Thus, is it safe to do
>>>> Array.prototype.slice.call
>>>> on any nodelist returned by querySelectorAll? I haven't thought of a
>>>> case yet where
>>>> this wouldn't be a bad idea, let me know.
>>>>
>>>> Also, if nobody helps it's no big deal, as I will be adding selectors
>>>> to it over the coming weeks,
>>>> so if you're into bookmarking it might be worth coming back for a
>>>> second or third look.
>>>>
>>>> --
>>>> 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]
>>>>
>>>> --
>>>> 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]
>>>
>>> --
>>> 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]
>>
>> --
>> 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]
>
> --
> 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]
>

-- 
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]

Reply via email to