Re: Better Variables through Custom Properties

On Thu, Oct 27, 2011 at 5:22 PM, L. David Baron <dbaron@dbaron.org> wrote:
> On Wednesday 2011-10-26 11:57 -0700, Tab Atkins Jr. wrote:
>> On Wed, Oct 26, 2011 at 11:41 AM, L. David Baron <dbaron@dbaron.org> wrote:
>> > Do all data-* properties inherit by default, or is there any
>> > provision for such properties that do not?  (I'm not sure if there
>> > needs to be; I'm just trying to understand what the model you're
>> > proposing is.)
>>
>> My intention is that they all inherit by default.
>
> OK, so my next question:  the values of data-* properties are
> essentially streams of values (or tokens).  What needs to happen to
> come up with a computed value for such a property (prior to
> inheritance)?  Most importantly, do data() expressions inside that
> stream get evaluated when finding the computed value of a data-*
> property (and the result inherited), or are the data() expressions
> retained through inheritance and computed at the destination?

data() expressions are evaluated (/substituted?) at computed-value
time.  That seems necessary to get sane behavior out of normal
properties using data() expressions.

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.

> In other words, given:
>
> <style>
>  #one { data-a: blue; data-b: data(a); }
>  #two { data-a: fuchsia; color: data(b); }
> </style>
> <div id="one">
>  <div id="two"></div>
> </div>
>
> do you end up with div "two" being blue or fuchsia?

Definitely blue.  There's a more complex example of this in the spec
currently (issue near the bottom of section 2).  Note that I'm still
in the middle of rewriting the spec to use the data properties, so
only section 2 is sane right now; the rest of the spec is talking
about the older proposal.

~TJ

Received on Friday, 28 October 2011 07:10:54 UTC