Re: Better Variables through Custom Properties

On Fri, Oct 28, 2011 at 8:50 AM, L. David Baron <dbaron@dbaron.org> wrote:
> On Friday 2011-10-28 00:08 -0700, Tab Atkins Jr. wrote:
>> I'm not entirely certain whether other types of values, such as 'em'
>> units, should resolve or not.  I suspect it's saner to resolve
>> everything that would normally be resolved at computed-value time.
>
> I don't see how you can resolve things like 'em' units.  For
> example, the following sets of declarations mean different things:
>
>  font-size: 2em; /* multiple of parent's font size */
>  width: 2em; /* multiple of element's font size */
>
>  color: currentColor; /* parent's color */
>  background-color: currentColor; /* element's color */
>  counter-reset: currentColor; /* identifier */
>
>  line-height: 100%; /* computed value is multiple of font-size */
>  vertical-align: 100%; /* computed value is multiple of line-height */
>  width: 100%; /* computed value is percentage */
>
> If you wanted to resolve things like these, you'd need to break them
> so that one of the above didn't work as authors would expect.
>
> Furthermore, if you wanted to resolve them at data-* computation
> time, you'd make data-* have dependencies on CSS properties, which
> makes the cyclic dependency detection substantially more
> complicated, since it would need to have an accurate representation
> of all of the dependencies between CSS properties (see [1]).  This
> cycle detection would in turn introduce compatibility problems that
> would prevent the working group from introducing new property
> dependencies in the future, since introducing a new CSS property
> dependency could turn data-* usage that was non-cyclic into
> something cyclic.

You're right.  Okay, so data properties only resolve their own
variables usage, nothing else.  The rest of the values are only
resolved when a variable is actually used in a property, because many
values requires that context before they can actually be resolved.

As well, I'd like to allow arbitrary functions and dimensions (since
data properties are useful for more than just variables), and having
to deal with some units resolving while others don't would be weird.

~TJ

Received on Friday, 28 October 2011 16:15:41 UTC