W3C home > Mailing lists > Public > public-css-archive@w3.org > December 2018

Re: [csswg-drafts] [css-values] if() function (#3455)

From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
Date: Thu, 20 Dec 2018 23:21:01 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-449170404-1545348060-sysbot+gh@w3.org>
> Obviously, we already have min max, but what's useful about if() is that, like toggle(), you can use it for any value.

This is, unfortunately, what makes this so much harder, and probably not capable of happening. In your example, you seem to be assuming that `100%` would be resolved as if it were a `width` value; I'm not sure why this should be the default.

Later, you talk about an alternate syntax that explicitly references other properties; this, unfortunately, means we're adding arbitrary dependencies between properties, something we've avoided doing so far because it's, in general, unresolvable.

Custom properties can arbitrarily refer to each other, but they're limited in what they can do, and have a somewhat reasonable "just become invalid" behavior when we notice a cycle. Cycles are more difficult to determine for arbitrary CSS, and can happen much more easily, because there are a number of *existing*, *implicit* between-property dependencies. For example, anything that takes a length relies on `font-size` (due to `em`), and so you can't have a value in `font-size` that refers to a property that takes a length (so no adjusting `font-size` to scale with `width`!). We add *new* dependencies of this sort over time (such as adding the `lh` unit, which induces a dependency on `line-height`); if authors could add arbitrary dependencies, we'd be unable to add new implicit ones for fear of breaking existing content (by forming cycles that were previous valid and non-cyclic).

`toggle()` gets away with its behavior because it's non-cyclic by definition, and relies solely on a dependency that already exists - the property's inherited value.  This, unfortunately, has no such escape-hatch.

So, unfortunately, we've had to reject ideas like this in the past, and as far as I can tell, there's nothing mitigating the problems in this proposal either. Sorry. :(

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3455#issuecomment-449170404 using your GitHub account
Received on Thursday, 20 December 2018 23:21:02 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:41 UTC