-
Notifications
You must be signed in to change notification settings - Fork 711
[css-om] Serialization of font-family names: quoted string vs keyword #5846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Gecko's code was originally implemented in https://bugzilla.mozilla.org/show_bug.cgi?id=1434802 (following even longer-standing behavior) and then got a few tweaks in https://bugzilla.mozilla.org/show_bug.cgi?id=1614348. I think the biggest constraint here is compat, and I'm a bit skeptic about the spec being compatible here... But happy to be proven wrong, this should be very easy to implement behind a flag and check for breakage... |
Is this a source of bugs? If not, we should just relax the requirement and say something like it has to be outputted in a form that round-trips. |
Blink basically does not add quote to a There is a bug though : https://w3c-test.org/css/cssom/font-family-serialization-001.html But it's easy to fix by always adding quotes if the name is the same as a I think the spec should clearly specify how to serialize |
It's also necessary to add quotes for font names that are the same as global values:
|
I am asking in this issue because it seems to be the most active, but it is a duplicate of #2350: for specified value, why not just serialize as specified by the author? Retaining more details of what the author originally wrote seems to be an implicit principle for specified values. Is it because browsers have to compare |
According to 6.7.2. Serializing CSS Values, the serialization of a font-family name should be "The string serialized as 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:
Note that the name is returned without quotes (even though it was specified as a quoted string).
Now try a multi-word family name:
Here, the result is quoted.
Furthermore:
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:
serializes as such, while the same name, quoted:
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:
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?
The text was updated successfully, but these errors were encountered: