8000 GitHub · Where software is built
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Allow parsing CSS variables with no value #4078
Closed
@nicolo-ribaudo

Description

@nicolo-ribaudo
.foo {
  --some-var: ;
}

CSS variables can be set to "nothing". There is some discussion about having some more explicit syntax for it (w3c/csswg-drafts#10441), but right now the only way to do so it to literally put nothing in the value. You can read more about the use cases at https://css-tricks.com/the-css-custom-property-toggle-trick/.

PDF.js, a popular library for rendering PDFs in the browser, recently started relying on it (mozilla/pdf.js#19879). It did so indirectly, through the PostCSS transform to polyfill the CSS light-dark() function (https://github.com/postcss/postcss-dark-theme-class), which injects this code:
@media (prefers-color-scheme: dark){

:root{
  --csstools-color-scheme--light:;
}
}

SASS cannot parse that code.

This issue is conceptually similar to #3245: that one was about the CSS variable fallback being set to nothing, while this one is about the declaration.

I'm happy to submit a PR.

Metadata

Metadata

Assignees

Labels

CSS compatibilitySupport the CSS specbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0