Skip to content

analyzeAnimation drops quoted animation names #612

@bartveneman

Description

@bartveneman

analyzeAnimation silently drops quoted animation names (<string> nodes)

@projectwallace/css-analyzer/valuesanalyzeAnimation

The CSS Animations spec defines <keyframes-name> as <custom-ident> | <string>, meaning quoted strings are valid animation names in both animation-name and the animation shorthand:

@keyframes "slide in" { from { opacity: 0 } to { opacity: 1 } }

a { animation-name: "slide in"; }          /* valid */
a { animation: "slide in" 1s ease; }       /* valid */

analyzeAnimation only processes is_identifier, is_dimension, and is_function nodes. is_string nodes are silently skipped, so quoted animation names produce no callback at all — they're invisible to callers.

Expected: analyzeAnimation calls the callback with { type: 'name', value: <StringNode> } for string nodes that appear in the name position.

Actual: the callback is never invoked; the quoted name is dropped entirely.

This also means atrules.keyframes in the full analyze() output will show quoted keyframe names as unused even when they are referenced by a quoted animation-name value.


Workaround we're currently using in stylelint-plugin:

analyzeAnimation(ast, ({ type, value }) => {
    if (type === 'name') tracker.use(value.text)
})
// analyzeAnimation doesn't handle <string> nodes — work around until fixed
for (const node of ast) {
    if (node.type === STRING) tracker.use(node.text)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 defectSomething isn't working as expected

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions