Re: [csswg-drafts] [css-env][css-conditional] Need an approach to check whether an environment variable is supported (#3576)

This would be particularly useful for [env(preferred-text-scale)](https://github.com/w3c/csswg-drafts/issues/10674). A site using this would likely need some conditional styles if the feature is supported. The only approaches that are available are the approach in https://github.com/w3c/csswg-drafts/issues/3576#issuecomment-2674473137, which doesn't work in Firefox, or javascript like the following, which has performance implications due to forcing a style recalc:
```
<script>
  let detector = document.createElement('div');
  detector.style = 'display: none; --preferred-text-scale-support: env(preferred-text-scale, -1px)';
  document.body.appendChild(detector);
  let style = getComputedStyle(detector).getPropertyValue('--preferred-text-scale-support');
  if (style.trim().toString() !== '-1px') {
    // supported!
  }
</script>
```
@davidsgrogan , @JoshTumath 

-- 
GitHub Notification of comment by progers
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3576#issuecomment-2881619620 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 14 May 2025 21:25:45 UTC