Bug 154669 - CSS.supports returns false for custom properties
Summary: CSS.supports returns false for custom properties
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: WebKit Nightly Build
Hardware: All OS X 10.11
: P2 Normal
Assignee: Ryosuke Niwa
URL: https://drafts.csswg.org/css-conditio...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-02-24 23:39 PST by yisibl
Modified: 2022-08-01 09:10 PDT (History)
20 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yisibl 2016-02-24 23:39:28 PST
1. Run CSS.supports('--foo', 'red') on the JavaScript console

What is the expected result?
true getting logged in the console

What happens instead?
false getting logged in the console

As custom properties (aka CSS variables) are now supported in Chromium, CSS.supports('--foo', 'red') should return true.
The alternative method signature using a conditionText works already correct and returns true for CSS.supports('(--foo: red)')

The related specification can be found here: 
https://drafts.csswg.org/css-conditional-3/#the-css-interface

See also: https://crbug.com/584683(Blink fixed)
Comment 1 David Kilzer (:ddkilzer) 2016-08-19 12:15:05 PDT
https://twitter.com/traviskaufman/status/766672149566423040
Comment 2 Serg Hospodarets 2017-04-21 15:21:16 PDT
Visual Demo- https://codepen.io/malyw/pen/OmXMYb
Comment 3 Serg Hospodarets 2017-04-21 15:47:00 PDT
The problem is, that this bug breaks most of the CSS Custom Properties detection examples across the Web.
And introduces inconsistencies and confusion as it works in CSS, but not in JS.
Comment 4 Radar WebKit Bug Importer 2017-04-21 17:54:26 PDT
<rdar://problem/31770186>
Comment 5 Ahmad Saleem 2022-07-30 06:39:24 PDT
I am able to reproduce this bug using test case from Comment 02 and Safari 15.6 on macOS 12.5 shows "FALSE" for "window.CSS.supports('--a', 0);" while all other browsers (Chrome Canary 106 and Firefox Nightly 105) show "TRUE". Just wanted to share updated test results. Thanks!
Comment 6 Ryosuke Niwa 2022-07-30 23:01:12 PDT
Pull request: https://github.com/WebKit/WebKit/pull/2881
Comment 7 EWS 2022-07-31 15:53:13 PDT
Committed 252987@main (69362356a5ab): <https://commits.webkit.org/252987@main>

Reviewed commits have been landed. Closing PR #2881 and removing active labels.