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.
I believe there an existing bug which may already cover this issue, but I can't find it in my quick skim through Bugzilla.
Created attachment 18758 [details] Minimal test case I've created minimal test case for this bug based on CSS3 Selectors test suite.
(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.
*** Bug 16706 has been marked as a duplicate of this bug. ***
Found another similar bug 9983.
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.
This has been taken care of.
*** Bug 9983 has been marked as a duplicate of this bug. ***