Re: [csswg-drafts] [all] Feature detection for CSS property support on certain elements (#4498)

> And different rendering contexts aren't just related to markup, it also includes different CSS layout types (`gap` for flex layout) or pseudo-elements.

For reference, that's covered in #3559. To keep things simple, I'd say to keep this issue restricted to properties support on specific elements and discuss cases like that one in the other issue.

> It would probably be better if there is some more automatic mechanism. But any such mechanism may also need extra work for implementations, so maybe not scalable either...

It's probably my naive understanding of how implementations work, but they obviously already have a way to distinguish different rendering contexts. Let's take the `clip-path` property mentioned before as an example. Somewhere in the code there must be a check for whether the property is used for rendering the element or not. So, simply spoken something like "if we're in HTML context, do this, if we're in SVG context do that".

At that point in the code it should be possible to "register" the context and signal back "yes, that property is understood in this context".

Once that mechanism for providing that info at render time is implemented, there wouldn't be anany extra work for implementors as it work work automatically. Though the big disadvantage of this solution is that you'll only know this information once you run through the rendering code at least once. So there is no centralized registration of all the properties beforehand.

Anyway, from an author perspective, this feature detection might look like this:

```css
@supports feature(<custom-ident> in <context>) {
   ...
}
```

where `<custom-ident>` would be the property name and `<context>` would be `html | svg | mathml`.

That makes it generally usable and avoids the introduction of keywords for specific feature checks.

Sebastian

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

Received on Friday, 22 November 2019 21:32:42 UTC