Skip to content

composes: silently accepts references to non-existent local classes #1215

@Kenzo-Wada

Description

@Kenzo-Wada

If you composes: a class that doesn't exist in the same file, lightningcss silently accepts it. The exports object
points to a hashed name that's never emitted as a CSS rule, so the class lands on the DOM but has no matching
styles. No error, no warning.

.historyChevron { color: blue; }

.historyChevronOpen {
  composes: historychevron; /* typo, real class is .historyChevron */
  transform: rotate(180deg);
}

cssModules: true, builds fine. color: blue never inherits.

postcss-modules-scope errors on this with referenced class name "historychevron" in composes not found
(source).

In src/css_modules.rs handle_composes, the same-file branch hashes name.0.as_ref() into a reference with no
lookup against exports_by_source_index. The cross-file branch does look up but silently continues on miss.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions