Re: [css3-values] use cases and the design of 'cycle()'

On Wed, May 2, 2012 at 9:51 AM, L. David Baron <dbaron@dbaron.org> wrote:
> On Wednesday 2012-04-25 08:44 -0700, L. David Baron wrote:
>> On Tuesday 2012-04-10 02:11 +0800, Kang-Hao (Kenny) Lu wrote:
>> > While reviewing CSS3 V&U, I realized that 'cycle()' doesn't really solve
>> > a use case I thought it would solve.
>> >
>> > Use Case A: In a User Interface built by nesting elements (say,
>> > <table>), set background color on the elements alternatively along the
>> > nesting level. See picture[1]
>>
>> Yes, it doesn't solve this case alone.  (I've also never seen any
>> other examples of this case.)
>>
>> It does solve this case in combination with variables, though, and
>> I think that's a better solution than making cycle() more complex.
>>
>> For example:
>>
>>   table {
>>     var-cycling-background: cycle(white, gray);
>>     background: var(cycling-background);
>>   }
>
> Actually, I don't think this works, because the thing that's
> inherited with variables is syntactic rather than semantic so the
> cycle() behavior wouldn't get applied until it's used.

Yup, you're right.  Bad on me for not catching this.

I see two possible solution, then:

1) Go back to the function containing an explicit identifier, and
selecting the index based on how many ancestors use that identifier,
or

2) Create some way to force variable evaluation.  You'd need to supply
a property context somehow.

~TJ

Received on Sunday, 6 May 2012 14:21:05 UTC