#6838 closed bug (wontfix)
:first selector behaves differently between IE8 and FF 3.6.8
Reported by: | grimace | Owned by: | john |
---|---|---|---|
Priority: | low | Milestone: | 1.7 |
Component: | selector | Version: | 1.4.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
I have the following html snippet:
<h1>Header</h1> <div class="Item">Item 1</div> <div class="Item">Item 2</div>
If I release the following selectors on it:
$(".Item:not(:first)") $(".Item:not(.Item:first)")
I get Firefox to return 2 in both cases. IE8 will return 1 in the first case, and 2 in the second.
Attachments (1)
Change History (23)
comment:1 Changed 12 years ago by
Component: | core → selector |
---|---|
Keywords: | first added; selectors removed |
comment:3 Changed 12 years ago by
Milestone: | 1.4.3 → 1.4.4 |
---|---|
Priority: | → blocker |
Status: | new → open |
Version: | 1.4.2 → 1.4.3 |
comment:4 Changed 12 years ago by
I've found that this works in Firefox 3.6.10, but not in IE8 ( but works fine for both when :last is used ):
alert( $(".Item:not(:first)").length ); alert( $(".Item:not(.Item:first)").length );
But this works in both ( returns 1 for length)
alert( $(".Item").not(":first").length ); alert( $(".Item").not(".Item:first").length );
comment:5 Changed 12 years ago by
You gave me an idea when you said that $(":first") returns Html node for Firefox and Doctype comment for IE 8.
That would mean than the root (:root) would be different in each browser (well IE 8 anyways)
So I tried the following, adding body (html works too) in to the mix to give it a different root:
$("body .Item:not(:first)") //length of 1 for both $("body .Item:not(.Item:first)") //length of 1 for both
And this works.
It seems if a different root is prepended to it, and not letting Sizzle set the root, then it works.
You can find a test of it here
Hope this is of some help.
comment:6 Changed 12 years ago by
Milestone: | 1.4.4 → 1.4.5 |
---|
Retargeting due to severity of regressions in 1.4.3.
comment:7 Changed 12 years ago by
Milestone: | 1.4.5 → 1.4.4 |
---|
Retargeting for 1.4.4 as per John’s request.
comment:8 Changed 12 years ago by
Owner: | set to john |
---|---|
Status: | open → assigned |
comment:10 Changed 12 years ago by
Milestone: | 1.4.5 → 1.6 |
---|
I want to save this for 1.6 when the selector rewrite happens - a lot of this code will be changing and there's not much point in fiddling with it now.
comment:11 Changed 12 years ago by
Milestone: | 1.6 → 1.next |
---|
comment:12 Changed 12 years ago by
Keywords: | 1.7-discuss added |
---|
Nominating ticket for 1.7 discussion.
comment:13 Changed 12 years ago by
Description: | modified (diff) |
---|
+0, If it's a bug, it should be fixed, but this seems awkward
comment:14 Changed 12 years ago by
+0, Smells fishy... need a fiddle to see if document structure is the problem here.
comment:15 Changed 12 years ago by
Description: | modified (diff) |
---|
+0, I guess that if it's a bug, then we should fix it, but also, there's a :gt selector for this...
comment:17 Changed 12 years ago by
Description: | modified (diff) |
---|
-1, Let's push folks towards standards selectors and not muck around here.
comment:18 Changed 12 years ago by
Description: | modified (diff) |
---|
+0, Ugh... :first semantics inside :not(), just terrible.
comment:19 Changed 12 years ago by
+0, There's clearly a bug in there and I wonder if it exists with other selectors too. However, I'm guessing this is really tricky to fix and there's an existing, better way to do the same thing.
comment:22 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Keywords: | first 1.7-discuss removed |
Milestone: | 1.next → 1.7 |
Priority: | blocker → low |
Resolution: | → wontfix |
Status: | assigned → closed |
It seems like the correct answer would be 2 for the first case and 1 for the second. If everyone agrees, then IE8 gets it right in my test case and Firefox gets the first case wrong.
The :first element for Firefox 3.6 is the HTML element; in IE it's the !DOCTYPE comment element. In general it seems like a bad idea to use an unqualified :first selector but the Firefox behavior seems pretty strange.