Skip to content

[css-animations] Consider accepting string as animation name #118

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

Closed
upsuper opened this issue May 17, 2016 · 11 comments
Closed

[css-animations] Consider accepting string as animation name #118

upsuper opened this issue May 17, 2016 · 11 comments
Assignees
Labels
css-animations-1 Current Work

Comments

@upsuper
Copy link
Member

upsuper commented May 17, 2016

WebKit's implementation supports using a string after @keyframes and animation-name. Blink supports this syntax for prefixed stuffs but not for unprefixed ones.

We've seen a website depends on this syntax (webcompat/web-bugs#2337). Not sure how widely this kind of thing is used, but in general, I guess it is not a bad idea to accept string as animation name.

I raised this for the compat spec (whatwg/compat#43) but it'd probably better to be discussed in CSSWG.

@birtles birtles added the css-animations-1 Current Work label May 17, 2016
@tabatkins
Copy link
Member

I'm fine with allowing this. Ignoring compat, it lets authors provide animation names without risk of them being misparsed for accidentally coinciding with one of the other animation keywords.

@birtles
Copy link
Contributor

birtles commented May 31, 2016

I started working on the edits for this but I'm wondering, is this sufficient?
https://github.com/w3c/csswg-drafts/compare/birtles/allow-strings-for-animation-name

@upsuper
Copy link
Member Author

upsuper commented Jun 2, 2016

It seems there is a grammar in section 4 just before 4.1, which is not updated.

@upsuper
Copy link
Member Author

upsuper commented Jun 2, 2016

And I think it would also be good to make it clear whether there is any difference between rules defined with a string name and those with an identifier name.

I guess (but not verified carefully) that current implementations which support it would treat ident and "ident" identically. If so, we should probably write that into the spec explicitly.

@astearns astearns removed the Agenda+ label Jun 4, 2016
@tabatkins tabatkins self-assigned this Jun 22, 2016
@tabatkins
Copy link
Member

We resolved in the telcon to accept this.

@yisibl
Copy link
Contributor

yisibl commented Mar 27, 2022

I'm going to fix the error that esbuild's CSS parser warning when parsing @keyframes <string> { }. So, I've spent a lot of time sorting out this change.

$ esbuild test.css --minify
▲ [WARNING] Expected identifier but found "\"foo\""

    m.css:1:11:
      1 │ @keyframes "foo"  {
        ╵            ~~~~~

1 warning
@keyframes ""{0%{background:#00f}to{background:green}}

This is really messed up. I hope that such compatibility issues can be avoided or reduced in the future, and that the addition of string brings a greater cost to other parsers.

@yisibl
Copy link
Contributor

yisibl commented Mar 27, 2022

@nt1m Says: #6405 (comment)

I agree supporting both string and ident is not ideal in the long run. It's typically the type of thing that becomes a quirk on the web platform and small maintenance burden for the engine (which accumulate).

@birtles
Copy link
Contributor

birtles commented Mar 28, 2022

Per that bug, looks like CSS wasn't using WPT at that point in time:

Once the CSSWG moves its tests to web-platform-tests we can work on splitting that mammoth test up into smaller (cross-browser) tests.

@yisibl
Copy link
Contributor

yisibl commented Mar 28, 2022

@birtles Thank you for the additional information, do you have plans to update WPT?

@yisibl
Copy link
Contributor

yisibl commented Mar 28, 2022

The <string> syntax also seems to make browser serialization more difficult, leading to inconsistencies across browsers, see also: #5846

@birtles
Copy link
Contributor

birtles commented Mar 28, 2022

@birtles Thank you for the additional information, do you have plans to update WPT?

I'm afraid I don't, at this stage. I was working on rewriting the WPT for CSS Animations before I left Mozilla but ran out of time to finish it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-animations-1 Current Work
Projects
None yet
Development

No branches or pull requests

5 participants