Re: [csswg-drafts] [css-variables] Substitution of invalid variables into other variables (#5370)

No worries! I'm glad the example was helpful

Catching an exception sounds like the right track and I love the idea of an inline customizable fallback...
Perhaps `--bigger: try(calc(var(--other) * 5, initial);` ?

> On the other hand, it seems easy to solve this problem in practice by just having the outer element of the component reset all the custom properties that shouldn't cross the boundary, and then an inner element can (attempt) to set the actual values for those properties.

Yep, this is how I've worked around it in my library. It may be easy for small libraries but the real-world cost of my project is:
1) **107 lines of CSS** in a new `[data-mylibrary-reset]` selector, using the `initial` keyword on every _conceptually-internal_ variable that may compute to initial.
2) End user pain point and maintenance concern that they must use an additional DOM layer to achieve nesting
3) Added complexity in documentation and tests
4) Had to remove several features where pseudo element overrides were previously possible (this can be simulated with 2 additional DOM elements now though, but that's a much bigger ask for an end user and the library developer)

---

`@property` is a good call out too though. We (library developers) may have to register hundreds of them to prevent the behavior, and deliberately `inherit` what's needed on pseudo children, but it is a path that solve the problem, just in a different and somewhat expensive way. (assuming `inherit` doesn't trigger this behavior and stops at the parent)

That inline fallback for `validate/try` that you came up with though would be an incredibly useful addition. I'm all for that

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


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

Received on Wednesday, 29 July 2020 20:32:14 UTC