Re: [csswg-drafts] [css-conditional] testing support of properties and values with partial implementations (#3559)

I just had an idea for a solution to this: Custom `@supports` rules.

Similar to [script-based custom media queries](https://drafts.csswg.org/mediaqueries-5/#script-custom-mq), we could introduce custom `@supports` rules. Those would allow to register some JavaScript worklet executing code like the one suggested by @Dan503.

The big advantage would be that authors could use `@supports` in their CSS context. The only part in JS would be the check for the support. Another advantage would be the great flexibility allowing authors to create any kind of check, possibly even beyond CSS related things.
The downsides of this proposal are that executing that code can slow down CSS evaluation and worklets generally don't have access to the DOM. Though I'd say the slow-down in evaluation is neglectable because the script only has to be executed once when parsing the CSS. The bigger issue which I didn't give much thought yet is probably the DOM access. I assume the access probably needs to be restricted somehow to avoid performance and/or privacy problems.

Sebastian

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


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

Received on Monday, 2 May 2022 06:43:24 UTC