Bug 11384

Summary: CSS2/3: Selectors are not re-evaluated after dynamically updating the DOM (Acid3 bug)
Product: WebKit Reporter: Niels Leenheer (HTML5test) <info>
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: allan.jensen, bdakin, eric, michiel, mrowe, webkit
Priority: P2 Keywords: HasReduction
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
URL: http://www.css3.info/selectors-test/
Bug Depends on: 17143    
Bug Blocks: 11390, 17064    
Attachments:
Description Flags
Minimal test case none

Description Niels Leenheer (HTML5test) 2006-10-23 02:43:41 PDT
After the DOM is modified the CSS selectors should be re-evaluated. 
Affected selectors: :first-child, :last-child, :only-child, :first-of-type, :last-of-type, :only-of-type, :empty

For example: an element that used to be empty would match the :empty selector. If the update added a new child to that element, it should no longer match  the :empty selector. 

Another example: an element that is the only child of its parent would match the following selectors: :first-child, :last-child, :only-child, :first-of-type, :last-of-type and :only-of-type. If we modify the DOM and append another child of the same type, the original element would only match the :first-child selector.
Comment 1 Mark Rowe (bdash) 2007-01-07 02:50:10 PST
I believe there an existing bug which may already cover this issue, but I can't find it in my quick skim through Bugzilla.
Comment 2 Robert Blaut 2008-01-29 00:32:11 PST
Created attachment 18758 [details]
Minimal test case

I've created minimal test case for this bug based on CSS3 Selectors test suite.
Comment 3 Robert Blaut 2008-01-29 00:54:36 PST
(In reply to comment #1)
> I believe there an existing bug which may already cover this issue, but I can't
> find it in my quick skim through Bugzilla.

After searching I've found three reports similar to this bug: bug 12519, bug 12520, bug 16706. 

Comment 4 Robert Blaut 2008-01-29 04:42:37 PST
*** Bug 16706 has been marked as a duplicate of this bug. ***
Comment 5 Robert Blaut 2008-01-30 14:37:36 PST
Found another similar bug 9983.
Comment 6 Robert Blaut 2008-01-30 15:06:19 PST
Interesting behavior regarding test case found by Alexey:

1. Open the test case in a new tab in background.
2. Don't activate the background tab unless it loads completely.
3. Switch to the background tab and you see the test case passed.

IMO this behavior is caused by the fact that styles are applied when the page becomes visible (not earlier). So the styles are applied on modified DOM tree. The styles don't need to be re-evaluated.

Comment 7 Dave Hyatt 2008-02-02 02:49:13 PST
This has been taken care of.

Comment 8 Robert Blaut 2008-02-21 22:19:21 PST
*** Bug 9983 has been marked as a duplicate of this bug. ***