Bug 33479 - Replacing hidden element causes first-child selector to behave weirdly
Summary: Replacing hidden element causes first-child selector to behave weirdly
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows 7
: P2 Normal
Assignee: Nobody
URL: http://gamca.informacie.sk/betatest/w...
Depends on:
Reported: 2010-01-11 11:10 PST by NovakP
Modified: 2010-03-14 01:46 PST (History)
1 user (show)

See Also:

[REDUCTION] Simple HTML/CSS/JS Showing The Problem (1.23 KB, text/html)
2010-03-13 22:03 PST, Joseph Pecoraro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description NovakP 2010-01-11 11:10:05 PST

I found bug in first-child rendering:
In provided testcase (see URL), clicking on link replaces hidden TD element #first using jQuery 1.4 method replaceWith() with another element. However, WebKit fails to render it correctly, because it hides not only replaced :first-child (as it should), but also second TD child of table row. And when I looked into Web Inspector, it says that second TD child is visible.

When I replaced :first-child by :first-of-type or even :nth-child(1) (in the testcase these are equal), everything works as expected.

This issue occurs in stable Webkit browsers versions and also in nightly builds of Webkit.

I reported this issue to jQuery team, but they said it's not bug in their library.
Comment 1 Joseph Pecoraro 2010-03-13 22:03:28 PST
Created attachment 50668 [details]
[REDUCTION] Simple HTML/CSS/JS Showing The Problem

Attached a simpler reduction. Whenever a new first child element is inserted into a :first-child position where a :first-child selector has display:none, then any existing element affected by the :first-child selector is not updated correctly.  Notes: This is not specific to <td>s. The exact same problem happens with :last-child and inserting the new element as the last child (appendChild instead of insertBefore). I did not test :only-child.