Last Comment Bug 988694 - css content from attribute does not work with multi-lines
: css content from attribute does not work with multi-lines
Status: RESOLVED INVALID
:
Product: Core
Classification: Components
Component: CSS Parsing and Computation (show other bugs)
: 28 Branch
: x86_64 All
-- normal (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
: Jet Villegas (:jet)
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-03-26 19:38 PDT by Rob G
Modified: 2014-04-02 10:35 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard: [bugday-20140402]
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments

Description User image Rob G 2014-03-26 19:38:14 PDT
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release)
Build ID: 20140314220517

Steps to reproduce:

When a data-attribute contains a "\A" to have the content show on multiple lines, it does not render the same as when the content is explicitly set. See this jsFiddle to make this more clear: http://jsfiddle.net/96pwE/


Actual results:

when "content: attr(data-zzz)" is used, the "\A" within the data-zzz attribute is rendered as plain text


Expected results:

The "\A" should be treated like a carriage return when the white-space is set to pre
Comment 1 User image [:Aleksej] 2014-04-02 08:12:23 PDT
http://www.w3.org/TR/CSS21/generate.html#propdef-content says:

attr(X)
    This function returns as a string the value of attribute X for the subject of the selector. The string is not parsed by the CSS processor.
Comment 2 User image [:Aleksej] 2014-04-02 08:19:05 PDT
> http://www.w3.org/TR/CSS21/generate.html#propdef-content says:

That's old, of course.

https://developer.mozilla.org/en-US/docs/Web/CSS/attr says with the default type, string, "the attribute value is parsed as a CSS <string>", which supports escaping. https://developer.mozilla.org/en-US/docs/Web/CSS/string

Reproduced with 2014-04-02-03-02-01-mozilla-central-firefox-31.0a1.en-US.linux-x86_64
Comment 3 User image [:Aleksej] 2014-04-02 08:21:50 PDT
Though https://developer.mozilla.org/en-US/docs/Web/CSS/white-space says "pre" means "sequences of whitespace are preserved, lines are only broken at newline characters in the source and at <br> elements."

Is that "\A" a newline character in the source?
Comment 4 User image [:Aleksej] 2014-04-02 08:32:59 PDT
http://www.w3.org/TR/css3-values/#attr-notation (found in bug 435426) says it "does not reparse".  Maybe the developer.mozilla.org article is wrong at the time.
Comment 5 User image Rob G 2014-04-02 09:12:58 PDT
Webkit doesn't support this either, but I think it would make sense to have content work consistently with either a string or attr(X).
Comment 6 User image Boris Zbarsky [:bz] (still a bit busy) 2014-04-02 10:03:47 PDT
That devmo page is quoting an old spec draft, which didn't say what it meant to say.  There is no reparsing that's supposed to happen here.

If you want to embed a newline in your attribute, you just do that (either via explicit newlines, HTML escapes, \n in a JS call to setAttribute, whatever).

I've fixed the devmo page.
Comment 7 User image Rob G 2014-04-02 10:28:44 PDT
There is no way to add new lines that I know of.

Here is an example using javascript: http://jsfiddle.net/96pwE/4/ (the "\A" is replaced by just "A"; "\n" doesn't work either).

Adding "<br>" (or any HTML) doesn't work.

Which demo page did you fix?
Comment 8 User image Boris Zbarsky [:bz] (still a bit busy) 2014-04-02 10:35:57 PDT
> "\n" doesn't work either

You forgot white-space: pre on the tests after test1.  I fixed you fiddle to show a number of different ways of putting in a newline.  See http://jsfiddle.net/96pwE/5/

> Which demo page did you fix?

I fixed the documentation quoted in comment 2.

Note You need to log in before you can comment on or make changes to this bug.