Skip to content

Commit

Permalink
Merge pull request #7 from Hazzard13/main
Browse files Browse the repository at this point in the history
Add support for `calc()` within a calc.
  • Loading branch information
jaraco authored May 24, 2021
2 parents f026f8d + 64ac80f commit 70820c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v2.3.0
======

#7: Add support for a ``calc()`` within a ``calc()``.

v2.2.0
======

Expand Down
4 changes: 3 additions & 1 deletion cssutils/css/value.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,9 @@ def _setCssText(self, cssText):
),
)

_operant = lambda: Choice(_DimensionProd(self), _CSSVariableProd(self)) # noqa
_operant = lambda: Choice( # noqa:E731
_DimensionProd(self), _CalcValueProd(self), _CSSVariableProd(self)
)

prods = Sequence(
Prod(
Expand Down
10 changes: 10 additions & 0 deletions cssutils/tests/test_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ def test_cssText(self):
'calc(1 / 1px )': ('calc(1 / 1px)', 1, 'calc(1 / 1px)'),
'calc( 1*1px )': ('calc(1 * 1px)', 1, 'calc(1 * 1px)'),
'calc( 1 / 1px )': ('calc(1 / 1px)', 1, 'calc(1 / 1px)'),
'calc(calc(1px + 5px) * 4)': (
'calc(calc(1px + 5px) * 4)',
1,
'calc(calc(1px + 5px) * 4)',
),
'calc( calc(1px + 5px)*4 )': (
'calc(calc(1px + 5px) * 4)',
1,
'calc(calc(1px + 5px) * 4)',
),
'calc(var(X))': (None, 1, None),
'calc(2 * var(X))': (None, 1, None),
'calc(2px + var(X))': (None, 1, None),
Expand Down

0 comments on commit 70820c0

Please sign in to comment.