Skip to content

Commit f2b85b3

Browse files
committed
[css-values] Remove ability for percentages to resolve against numbers. Fixes #1463.
1 parent 43e5c50 commit f2b85b3

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

css-values-3/Overview.bs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1604,14 +1604,30 @@ Type Checking</h4>
16041604
are valid.
16051605

16061606
If percentages are accepted in the context in which the expression is placed,
1607-
a <<percentage-token>> has the type of the value that percentages are relative to.
1608-
For example, in the 'width' property, percentages have the <<length>> type,
1609-
and in 'opacity' they have the <<number>> type.
1607+
and they are defined to be relative to another type besides <<number>>,
1608+
a <<percentage-token>> is treated as that type.
1609+
For example, in the 'width' property, percentages have the <<length>> type.
16101610
A percentage only has the <<percentage>> type if in that context
16111611
<<percentage>> values are not used-value compatible with any other type.
16121612
If percentages are not normally allowed in place of the ''calc()'',
16131613
then a ''calc()'' expression containing percentages is invalid in that context.
16141614

1615+
Note: Note that <<percentage>>s relative to <<number>>s,
1616+
such as in 'opacity',
1617+
are not allowed in ''calc()''.
1618+
Allowing this would cause significant problems with "unit algebra"
1619+
(allowing multiplication/division of <<dimension>>s),
1620+
and in every case so far,
1621+
doesn't provide any new functionality.
1622+
(For example, ''opacity: 25%'' is identical to ''opacity: .25'';
1623+
it's just a trivial syntax transform.)
1624+
1625+
Note: Altho there are a few properties in which a bare <<number>>
1626+
becomes a <<length>> at used-value time
1627+
(specifically, 'line-height' and 'tab-size'),
1628+
<<number>>s never become "length-like" in ''calc()''.
1629+
They always stay as <<number>>s.
1630+
16151631
Operators form sub-expressions, which gain types based on their arguments.
16161632
To make expressions simpler,
16171633
operators have restrictions on the types they accept.

css-values/Overview.bs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1691,14 +1691,30 @@ Type Checking</h4>
16911691
are valid.
16921692

16931693
If percentages are accepted in the context in which the expression is placed,
1694-
a <<percentage-token>> has the type of the value that percentages are relative to.
1695-
For example, in the 'width' property, percentages have the <<length>> type,
1696-
and in 'opacity' they have the <<number>> type.
1694+
and they are defined to be relative to another type besides <<number>>,
1695+
a <<percentage-token>> is treated as that type.
1696+
For example, in the 'width' property, percentages have the <<length>> type.
16971697
A percentage only has the <<percentage>> type if in that context
16981698
<<percentage>> values are not used-value compatible with any other type.
16991699
If percentages are not normally allowed in place of the ''calc()'',
17001700
then a ''calc()'' expression containing percentages is invalid in that context.
17011701

1702+
Note: Note that <<percentage>>s relative to <<number>>s,
1703+
such as in 'opacity',
1704+
are not allowed in ''calc()''.
1705+
Allowing this would cause significant problems with "unit algebra"
1706+
(allowing multiplication/division of <<dimension>>s),
1707+
and in every case so far,
1708+
doesn't provide any new functionality.
1709+
(For example, ''opacity: 25%'' is identical to ''opacity: .25'';
1710+
it's just a trivial syntax transform.)
1711+
1712+
Note: Altho there are a few properties in which a bare <<number>>
1713+
becomes a <<length>> at used-value time
1714+
(specifically, 'line-height' and 'tab-size'),
1715+
<<number>>s never become "length-like" in ''calc()''.
1716+
They always stay as <<number>>s.
1717+
17021718
Operators form sub-expressions, which gain types based on their arguments.
17031719
To make expressions simpler,
17041720
operators have restrictions on the types they accept.

0 commit comments

Comments
 (0)