New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 649444 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 3
Type: Bug



Sign in to add a comment

CSS class selector .NNN don't match XML nodes

Reported by sebastie...@gmail.com, Sep 22 2016

Issue description

UserAgent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/52.0.2743.116 Chrome/52.0.2743.116 Safari/537.36

Example URL:
http://ffctn.com/doc/chrome-test-style.xml

Steps to reproduce the problem:
1. Open http://ffctn.com/doc/chrome-test-style.xml
2. Open http://ffctn.com/doc/chrome-test-style.html

What is the expected behavior?
Look at the color of the rectangles in (1) and (2). They should all be green.

What went wrong?
CSS rules matching classes (eg. `.GREEN`) do no match XML nodes with non HTML/SVG-namespaced nodes with a `class='GREEN'` attribute.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 52.0.2743.116  Channel: n/a
OS Version: Ubuntu 16.04
Flash Version:
 

Comment 1 by f...@opera.com, Sep 23 2016

Components: -Blink Blink>CSS

Comment 2 by r...@opera.com, Sep 23 2016

Status: WontFix (was: Unconfirmed)
I think Gecko is wrong. [1] says which attribute is a class is document language specific. The bookmarks namespace used in that test is unknown to Blink and we should not assume the class attribute is a class.

[1] https://drafts.csswg.org/selectors-4/#class-html

Well,in practice that means that we can't use `.NNN` selectors in CSS to style XML nodes. It's true that you can't expect XML nodes to have a class attribute, or the class attribute to mean the same thing as in HTML, but that shouldn't prevent you from styling it. 

More to the point, if a node in any namespace has a class attribute, it would seem natural to expect that the `.NNN` works the same as `*[class=~"NNN"]`. 

I have updated the examples and you'll see that while `.NNN` does not work, the more verbose form does.

http://ffctn.com/doc/chrome-test-style.xml

Wouldn't you agree that if the `.NNN` and `*[class=~"NNN"]` forms are semantically equivalent (modulo the selector priority), they should behave, consistently?

Comment 4 by r...@opera.com, Sep 26 2016

Cc: r...@opera.com
Labels: -Pri-2 Hotlist-Interop Pri-3
Status: Available (was: WontFix)
I agree it would be convenient if the attribute named class behaves as a class in terms of class selectors for every xml document type. If so, I think the relevant CSS spec needs to change. You could try bringing this up as an issue for the Selectors spec at w3c.

If both Gecko and Edge treats all attributes named class the same, we should probably reconsider. I've re-opened this for now marked it as an interop issue.

Comment 6 by r...@opera.com, Sep 26 2016

This one too:

https://bugzilla.mozilla.org/show_bug.cgi?id=89982

I'm not able to find an issue where Gecko actually decided to support it.

I filed an issue in the Selectors spec, https://github.com/w3c/csswg-drafts/issues/534
This might be relevant as well: https://bugzilla.mozilla.org/show_bug.cgi?id=741295 (ie. Gecko treating @class and @id in the same way for any element).
So here's the DOM spec https://dom.spec.whatwg.org/#dom-element-classname

"id, class, and slot are effectively superglobal attributes as they can appear on any element, regardless of that element’s namespace."

So it would make sense to follow Gecko's interpretation https://bugzilla.mozilla.org/show_bug.cgi?id=741295


Comment 10 by r...@opera.com, Sep 26 2016

Components: -Blink>CSS Blink>DOM
OK. Changing component as a fix would happen in the DOM code so that blink::Element::classNames() returns a SpaceSplitString for class in other namespaces than HTML and SVG as well.

Components: Blink>XML
Thank you both for digging into this. I'll tag this with XML since it's an issue for people using XML, even if the fix is in DOM.
Awesome, thanks!
Components: -Blink>DOM
Project Member

Comment 14 by sheriffbot@chromium.org, Jul 11

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Problem is still occurring as of 2018-07-11 67.0.3396.99 
Components: Blink>DOM
Status: Available (was: Untriaged)
Yes, nobody has touched this one.

Sign in to add a comment