WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
4812
CSS3: buggy :last-child pseudo selector (Acid3 bug)
https://bugs.webkit.org/show_bug.cgi?id=4812
Summary
CSS3: buggy :last-child pseudo selector (Acid3 bug)
Simon Percivall
Reported
2005-09-02 11:20:48 PDT
Styling a <li> with li:last-child:after will style each <li>, instead of only the last. This happens with embedded styles and with a linked style the first time the page loads.
Attachments
Test-case to show problem
(528 bytes, application/xhtml+xml)
2005-09-02 11:22 PDT
,
Simon Percivall
no flags
Details
Patch to implement last-child and last-of-type
(161.20 KB, patch)
2008-02-02 02:29 PST
,
Dave Hyatt
oliver
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Simon Percivall
Comment 1
2005-09-02 11:22:26 PDT
Created
attachment 3723
[details]
Test-case to show problem The file shows embedded styles. It works (like I believe it should, anyway) in Gecko. If you link the CSS, it'll work after a reload.
Mark Rowe (bdash)
Comment 2
2005-09-03 01:58:19 PDT
Confirmed with WebKit 412.7 and ToT. The behaviour seems quite arbitrary -- on some page loads it appears as "[ test1 ] test2 > test3 ]" which means it is correct for one of the <li> tags. Other times it gets rendered as "[ test1 ] test2 ] test3 ]". With ToT refreshing the page results in correct results until the cache is emptied. With WebKit 412.7 refreshing occasionally results in the correct rendering, but more often seems to result in one of the three incorrect renderings (the third being "[ test1 > test2 ] test3 ]").
Gerrit Kaiser
Comment 3
2005-09-22 14:36:24 PDT
Discovered this bug as well (WebKit 412.5). In embedded WebKit-Views it a CSS rule is applied to all child element (not only the last) and stays that way, Safari shows this only right after page load in my test. See
http://planetgk.de/tests/safari/lastchild.html
Nicholas Shanks
Comment 4
2005-10-12 06:21:06 PDT
This has been present for a long time and is discussed in other places such as
bug #3442
(which was originally supposed to fix it, but the fix got rejected and that bug is more limited in scope now).
mitz
Comment 5
2006-04-16 13:12:54 PDT
***
Bug 8426
has been marked as a duplicate of this bug. ***
mitz
Comment 6
2006-04-16 13:13:36 PDT
Bug 8426
includes a different test case. See also
bug 5287
.
Jonathan del Strother
Comment 7
2006-05-09 02:06:33 PDT
I'm not sure if this adds anything useful, but thought I'd point out that dynamically created parents don't suffer from this problem. (eg create a new ul with javascript, and it's fine. Simply adding an li child to an existing ul leaves you with the same problem, though.) <a href="
http://www.steelskies.com/download/lastChild.htm
">for example</a>
mitz
Comment 8
2006-12-16 14:26:23 PST
***
Bug 9840
has been marked as a duplicate of this bug. ***
Nicholas Shanks
Comment 9
2007-02-05 14:00:39 PST
why not remember the previous child element being worked on whilst processing the document, and when the parent closes, go back and re-style that child. That way the li:last-child matching element would only get processed when you encountered <ul> rather than in a second styling pass or something. if this can't be fixed in time for Leopard, recommend removing support for last-child (and related selectors) altogether. Better to not support at all than have completely incorrect implementation.
Allan Sandfeld Jensen
Comment 10
2007-08-14 07:28:04 PDT
Correctly implementing :last-child is directly related to correctly implementing :empty. Both has to trigger a restyle when a close tag is parsed. :last-child needs a restyle of the last child-element, and :empty requires a restyle of the closing element. Also both could be solved by always waiting to create the style until the next tag and potential element have been parsed. And both are sensitive to Element.appendNode where they may need to trigger a restyle of the previous sibling or the parent node.
Eric Seidel (no email)
Comment 11
2008-01-01 22:15:19 PST
Test 35 (and possibly test 0) in Acid3 hit this bug.
Eric Seidel (no email)
Comment 12
2008-01-06 16:59:57 PST
I don't believe hyatt is actively working on this, reassigning to unassigned.
Dave Hyatt
Comment 13
2008-02-02 02:29:21 PST
Created
attachment 18868
[details]
Patch to implement last-child and last-of-type
Oliver Hunt
Comment 14
2008-02-02 02:40:24 PST
Comment on
attachment 18868
[details]
Patch to implement last-child and last-of-type r=me! Go team hyatt!
Dave Hyatt
Comment 15
2008-02-02 02:48:34 PST
Fixed in
r29933
.
Nicholas Shanks
Comment 16
2008-02-02 06:27:52 PST
:only-child and :only-of-type are easy now, since they just need to check that :first-… and :last… are both true. I would have suggested doing that in this patch if you hadn't already checked it in.
Dave Hyatt
Comment 17
2008-02-02 11:25:41 PST
Yes, I've done only-child and only-of-type. That's coming in my next check-in.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug