New issue
Advanced search Search tips

Issue 681814 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

cssRules.selectorText doesn't return authored values correctly with hackish namespace prefix

Reported by tristan....@gmail.com, Jan 17 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:51.0) Gecko/20100101 Firefox/51.0

Steps to reproduce the problem:
1. set a rule set in the hackish [ns\:attr] form
2. try to read this rule-set via document.styleSheets[n].cssRules[n].selectorText

What is the expected behavior?
It should return [ns\:attr]

What went wrong?
It returns [ns:attr] which is not a valid selector, hence, making this selector unusable for further use.

Did this work before? No 

Does this work in other browsers? No
 Works as expected in FF
Doesn't work in Safari either

Chrome version: 55.0.2883.95 (64-bit)  Channel: stable
OS Version: OS X 10.9
Flash Version: Shockwave Flash 24.0 r0

I know the [ns\:attr] syntax is an hack and is not valid CSS  namespace prefix at first, but unfortunately, this hack is being used by some big libraries (https://docs.angularjs.org/api/ng/directive/ngCloak).

Also, this bug is almost impossible to workaround since FF does keep the authored value, which seems more friendly IMO (Safari has the same behavior as chrome and I don't know what IE does).
 
selector-bug-report.html
649 bytes View Download
Components: -Blink>DOM Blink>CSS
Labels: M-55 Needs-Feedback
Could you please let us know what is the expected value and where to check from Chrome Te side to further triage it.
681814_Jan_18.png
57.3 KB View Download
Please have a look at:
https://jsfiddle.net/e9oogu4v/1/
I'm not sure what should be the correct value.
Specs only talk about the correct [ns|attr] (U+007C) https://drafts.csswg.org/cssom/#serializing-selectors, but not about how incorrect characters forced by \ (U+005C) should be serialized. 
But as a user I did expect the serialization to return what was authored (i.e with the \ ).
If you can confirm that chromium behavior is the correct one, I'm ok to open an issue in Firefox's bug-tracker.
In a html-document, [my\:ms] is the only way to select namespaced attributes
http://stackoverflow.com/questions/24390558/css-attribute-namespace-selector-in-svg

If i escape an id-selector e.g. "#id\:" it works as expected.
Project Member

Comment 6 by bugdroid1@chromium.org, Jan 19 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/97b5d7d2b375ae960a7b8084591815e30ae19832

commit 97b5d7d2b375ae960a7b8084591815e30ae19832
Author: fs <fs@opera.com>
Date: Thu Jan 19 16:52:24 2017

Serialize type and attribute selectors as identifiers

Per [1], both the element name of a type selector and the attribute name
of an attribute selector - as well as their corresponding namespace
prefix (if any) - should be serialized as identifiers [2].

[1] https://drafts.csswg.org/cssom/#serialize-a-simple-selector
[2] https://drafts.csswg.org/cssom/#serialize-an-identifier

BUG= 681814 

Review-Url: https://codereview.chromium.org/2645563002
Cr-Commit-Position: refs/heads/master@{#444766}

[add] https://crrev.com/97b5d7d2b375ae960a7b8084591815e30ae19832/third_party/WebKit/LayoutTests/cssom/serialize-attribute-selectors.html
[modify] https://crrev.com/97b5d7d2b375ae960a7b8084591815e30ae19832/third_party/WebKit/LayoutTests/cssom/serialize-namespaced-type-selectors.html
[modify] https://crrev.com/97b5d7d2b375ae960a7b8084591815e30ae19832/third_party/WebKit/Source/core/css/CSSSelector.cpp

Comment 7 by f...@opera.com, Jan 19 2017

Labels: -OS-Mac
Owner: f...@opera.com
Status: Fixed (was: Unconfirmed)

Sign in to add a comment