Re: CSS Variables Draft Proposal

On Wed, Feb 16, 2011 at 4:18 PM, David Singer <singer@apple.com> wrote:
> On Feb 16, 2011, at 20:24 , Daniel Glazman wrote:
>> Le 16/02/11 08:26, David Singer a écrit :
>>> Is it harmful to have variables textually local to the document in which they occur?
>>
>> Assuming your "document" above means "stylesheet", my answer is yes.
>>
>>
>>  <link rel="stylesheet" type="text/css" href="corporate.css"/>
>>  <style type="text/css">
>>    .logo { content: $logoUrl; }
>>  </style>
>>
>> The above - a real test case real users have been asking for more than a
>> decade - is possible only because variables cross stylesheet boundaries.
>> If the logoUrl is changed by the corporate stylesheet, the web page is
>> visually updated w/o any action from the page author.
>
> Oh
>
> What I was suggesting that in the case, where outer.css says:
>
> @var $foo 10px;
> @import url('inner.css')
> div { width $foo }
>
> and inner.css(1) says
>
> div { height $foo }
>
> Then indeed, $foo cascades into the included stylesheet if it's not re-declared there.
>
> But if inner.css(2) says
>
> @var $foo red;
> p { color: $foo }
>
> then the div in outer still gets 10px, as the re-declaration in inner.css is no longer in scope, but paragraphs are red according to inner.css.  This is classical lexical scoping; $foo is shadowed in the nested scope.
>
> I am not sure what the scoping rule would be to enable what you give [above], and at the same time avoid unintended clashes/redefinitions.

The idea is that there *isn't* such a scoping rule.  We'll just solve
the clash problem with a separate mechanism.

~TJ

Received on Thursday, 17 February 2011 00:32:49 UTC