Bug 64372 - CSS attribute selector + descendant not styled correctly
Summary: CSS attribute selector + descendant not styled correctly
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: http://jsfiddle.net/aUCkn/
Depends on:
Reported: 2011-07-12 11:10 PDT by bug
Modified: 2022-07-12 14:57 PDT (History)
4 users (show)

See Also:

Patch with failing layout test (2.94 KB, patch)
2011-07-12 20:09 PDT, Dominic Cooney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bug 2011-07-12 11:10:20 PDT
When using the attribute selector in combination with a descendant, styles are not being applied correctly.

Test: http://jsfiddle.net/aUCkn/
You may also take a look at http://stackoverflow.com/questions/6655364/css-attribute-selector-descendant-gives-a-bug-in-webkit/ where this bug is being discussed.
Comment 1 Dominic Cooney 2011-07-12 20:09:36 PDT
Created attachment 100613 [details]
Patch with failing layout test

The jsfiddle as a layout test.

Expected result: lines are blue/green/green.

Safari Version 5.0.4 (6533.20.27) fails—lines are blue/blue/blue.
Chrome 14.0.803.0 (Official Build 90483) dev Mac OS WebKit 535.1 (trunk@89703) fails—lines are blue/blue/green.
WebKit nightly r90810 fails—lines are blue/blue/green.
Firefox 5.0 passes.

It is interesting to note how sensitive this is to whitespace in the element with the attribute, as discussed on the StackOverflow bug. For example, if the first div[foo="green"] does not have child whitespace, then both div[foo="green"] render correctly (regardless of whitespace in the second one.)
Comment 2 daniel.baulig 2011-07-18 03:46:20 PDT
Just in case this will provide anything: I encountered a bug that seems to be related. I was made aware of this bug report when I posted a thread about the bug on SO: 
It also contains a jsFiddle which demonstrates the behaviour, allthough it is much more complex than dadu's fiddle:
Comment 3 Brent Fulgham 2022-07-12 14:57:16 PDT
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.