W3C home > Mailing lists > Public > public-css-archive@w3.org > January 2021

[csswg-drafts] [css-om] Serialization of font-family names: quoted string vs keyword (#5846)

From: jfkthame via GitHub <sysbot+gh@w3.org>
Date: Fri, 08 Jan 2021 13:44:38 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-782128250-1610113476-sysbot+gh@w3.org>
jfkthame has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-om] Serialization of font-family names: quoted string vs keyword ==
According to [6.7.2. Serializing CSS Values](https://drafts.csswg.org/cssom/#serializing-css-values), the serialization of a font-family name should be "The string [serialized as a string](https://drafts.csswg.org/cssom/#serialize-a-string)", where this means a string surrounded by literal ASCII double-quotes (and with any internal double-quotes or backslashes escaped).

However, AFAICT no browser consistently follows this.

For a family-name that is a single word (without special characters that would require quoting to be parsed), WebKit/Blink prefer to serialize the name as an unquoted keyword.

For example, from Safari's Javascript console:
```
> document.body.style.fontFamily = "'Times'"
< "'Times'"
> document.body.style.fontFamily
< "Times"
```
Note that the name is returned without quotes (even though it was specified as a quoted string).

Now try a multi-word family name:
```
> document.body.style.fontFamily = "'Times New Roman'"
< "'Times New Roman'"
> document.body.style.fontFamily
< "\"Times New Roman\""
```
Here, the result is quoted.

Furthermore:
```
> document.body.style.fontFamily = "Avenir Next"
< "Avenir Next"
> document.body.style.fontFamily
< "\"Avenir Next\""
```
Even when the family name was specified _without_ quotes, Safari adds them. (At least it seems consistent.)

Firefox takes a different approach; it seems to serialize the name according to how it was specified. So a name specified in unquoted form:
```
> document.body.style.fontFamily = "Times"
< "Times"
> document.body.style.fontFamily
< "Times"
```
serializes as such, while the same name, quoted:
```
> document.body.style.fontFamily = "'Times'"
< "'Times'"
> document.body.style.fontFamily
< "\"Times\""
```
returns a serialization that also has the quotes.

This holds for multi-word names, too; even then, Firefox returns an unquoted serialization if the name was specified in that form:
```
document.body.style.fontFamily = "Times New Roman"
"Times New Roman"
document.body.style.fontFamily
"Times New Roman"
```

So my question is whether implementers have any interest in aligning with the CSSOM spec here, in which case these are simply browser bugs to be fixed; or should the spec be adjusted to more closely match implementation reality?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5846 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 8 January 2021 13:44:41 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 19 October 2021 01:31:38 UTC