css content from attribute does not work with multi-lines




5 years ago
5 years ago


(Reporter: wowmotty, Unassigned)


28 Branch

Firefox Tracking Flags

(Not tracked)




5 years ago
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

5 years ago
http://www.w3.org/TR/CSS21/generate.html#propdef-content says:

    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.
QA Whiteboard: [bugday-20140402]
Component: Untriaged → CSS Parsing and Computation
OS: Windows 8 → All
Product: Firefox → Core
Whiteboard: [INVALID?]

Comment 2

5 years ago
> 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
Ever confirmed: true
Whiteboard: [INVALID?]

Comment 3

5 years ago
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

5 years ago
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

5 years ago
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).
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.
Last Resolved: 5 years ago
Resolution: --- → INVALID

Comment 7

5 years ago
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?
> "\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.
You need to log in before you can comment on or make changes to this bug.