Skip to content

Commit 2ae2276

Browse files
committed
[css-cascade-4] Define aliasing mechanisms. #866.
1 parent b3b3292 commit 2ae2276

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

css-cascade-4/Overview.bs

+56
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,62 @@ Shorthand Properties</h2>
283283
Declaring a <a>shorthand</a> property to be ''!important''
284284
is equivalent to declaring all of its <a>sub-properties</a> to be ''!important''.
285285

286+
<h3 id="aliasing">
287+
Aliasing</h3>
288+
289+
Properties sometimes change names after being supported for a while,
290+
such as vendor-prefixed properties being standardized.
291+
The original name still needs to be supported for compatibility reasons,
292+
but the new name is preferred.
293+
To accomplish this, CSS defines two different ways of “aliasing” old syntax to new syntax.
294+
295+
<dl export>
296+
<dt><dfn lt="legacy name alias">legacy name aliases</dfn>
297+
<dd>
298+
When the old property’s syntax is identical to
299+
or a subset of the value space of the new property’s syntax,
300+
the two names are aliased with an operation on par with case-mapping:
301+
at parse time, the old property is converted into the new property.
302+
This conversion also applies in the CSSOM,
303+
both for string arguments and property lookups:
304+
requests for the old property
305+
transparently transfer to the new property instead.
306+
307+
<div class=example highlight=js>
308+
For example, if
309+
<css>old-name</css> is a <a>legacy name alias</a> for <css>new-name</css>,
310+
<code>getComputedStyle(el).oldName</code>
311+
will return the computed style of the <code>newName</code> property,
312+
and <code>el.style.setPropertyValue("old-name", "value")</code>
313+
will set the <css>new-name</css> property to <code>"value"</code>.
314+
</div>
315+
316+
<dt><dfn lt="legacy shorthand">legacy shorthands</dfn>
317+
<dd>
318+
When the old property has a distinct syntax from the new property,
319+
the two names are aliased using the <a>shorthand</a> mechanism.
320+
These shorthands are defined to be <a>legacy shorthands</a>,
321+
and their use is <em>deprecated</em>.
322+
They otherwise behave exactly as regular shorthands,
323+
except that the CSSOM will not use them
324+
when serializing declarations. [[CSSOM]]
325+
326+
<div class=example>
327+
For example, the 'page-break-*' properties
328+
are <a>legacy shorthands</a> for the 'break-*' properties
329+
(see [[css-break-3#page-break-properties]]).
330+
331+
Setting 'page-break-before: always' expands to 'break-before: page' at parse time,
332+
like other shorthands do.
333+
Similarly, if 'break-before: page' is set,
334+
calling <code>getComputedStyle(el).pageBreakBefore</code> will return <code>"always"</code>.
335+
However, when serializing a style block
336+
(see [[cssom-1#serializing-css-values]]),
337+
the 'page-break-before' property will never be chosen as the shorthand to serialize to,
338+
regardless of whether it or 'break-before' was specified;
339+
instead, 'break-before' will always be chosen.
340+
</div>
341+
</dl>
286342

287343
<h3 id="all-shorthand">
288344
Resetting All Properties: the 'all' property</h3>

0 commit comments

Comments
 (0)