Skip to content

Commit 835d495

Browse files
committed
Added some explanatory notes to answer questions. These will be removed before WD publication.
1 parent d64033e commit 835d495

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

css-variables/Overview.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ <h2 id=defining-variables><span class=secno>2. </span> Defining Variables</h2>
268268

269269
<p>
270270

271+
<p class=note>I chose the $ prefix over the var() function for terseness.
272+
We should try to avoid nesting functions as much as reasonable, as it's
273+
hard to read. The $ is required in the variable definition as well as the
274+
variable use for consistency - every instance of the variable name within
275+
CSS has the same form.
276+
271277
<div class=example>
272278
<p>This variables declaration:</p>
273279

@@ -297,6 +303,14 @@ <h2 id=defining-variables><span class=secno>2. </span> Defining Variables</h2>
297303
imported within scoped stylesheets are only available within the scoped
298304
stylesheet and any imported stylesheets.
299305

306+
<p class=note>Making all variables global is the simplest solution that
307+
works, and is consistent with other at-rules that define names, like
308+
@font-face and @counter-style - the web seems to get by great on "ad-hoc
309+
scoping" via adding short prefixes. If it is shown that we need a more
310+
complex scoping solution in the future, I believe we can do so via a
311+
general scoping/namespacing mechanism that applies to all the at-rules
312+
that define names.
313+
300314
<p>A &lsquo;<code class=css>@var</code>&rsquo; rule is <dfn
301315
id=inactive-var-rule>inactive</dfn> if it's present in a disabled or
302316
alternate stylesheet, a stylesheet with a media query that evaluates to

css-variables/Overview.src.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ <h2 id="defining-variables">
108108

109109
<p>A ''@var'' rule defines a variable and assigns a value to it. It consists of the at-keyword ''@var'' followed by a variable name (an identifier starting with the "$" character), followed by the value and finally terminated with a semi-colon. The result of this rule is that the given value is assigned to the given variable name.<p>
110110

111+
<p class='note'>I chose the $ prefix over the var() function for terseness. We should try to avoid nesting functions as much as reasonable, as it's hard to read. The $ is required in the variable definition as well as the variable use for consistency - every instance of the variable name within CSS has the same form.</p>
112+
111113
<div class=example>
112114
<p>This variables declaration:</p>
113115

@@ -122,6 +124,8 @@ <h2 id="defining-variables">
122124

123125
<p>Defined variables are available to all stylesheets in the document. Thus, using ''@import'' to include a stylesheet also includes all variables defined in the stylesheet (and makes all variables declared outside available within the stylesheet, if applicable). ''@var'' rules present in disabled or alternate stylesheets do not define variables. Scoped stylesheets are an exception to this: variables defined in the global scope are available within a scoped stylesheet, but variables defined or imported within scoped stylesheets are only available within the scoped stylesheet and any imported stylesheets.</p>
124126

127+
<p class='note'>Making all variables global is the simplest solution that works, and is consistent with other at-rules that define names, like @font-face and @counter-style - the web seems to get by great on "ad-hoc scoping" via adding short prefixes. If it is shown that we need a more complex scoping solution in the future, I believe we can do so via a general scoping/namespacing mechanism that applies to all the at-rules that define names.</p>
128+
125129
<p>A ''@var'' rule is <dfn id='inactive-var-rule'>inactive</dfn> if it's present in a disabled or alternate stylesheet, a stylesheet with a media query that evaluates to false, or is present within a conditional rule group [[CSS3CONDITIONAL]] whose condition evaluates to false. <i>Inactive</i> ''@var'' rules do not define variables. All other ''@var'' rules are <dfn id='active-var-rule'>active</dfn>.</p>
126130

127131
<p>If new ''@var'' rules are added to the document through any means, such as direct CSSOM manipulation or new stylesheets being added to the document, or if an <i>inactive</i> ''@var'' rule becomes <i>active</i>, they define variables. Similarly, if ''@var'' rules are removed from the document or become <i>inactive</i>, they no longer define variables.</p>

0 commit comments

Comments
 (0)