Skip to content

Commit

Permalink
Handle legacy grid properties
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Apr 15, 2024
1 parent 2f07980 commit 41d735c
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions weasyprint/css/validation/expanders.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,17 +839,44 @@ def expand_grid_area(tokens, name):
yield f'grid-{side}', tokens


@expander('grid-gap')
@expander('gap')
@generic_expander('column-gap', 'row-gap')
def expand_gap(tokens, name):
"""Expand the ``gap`` property."""
if len(tokens) != 2:
if len(tokens) == 1:
if gap(tokens) is None:
raise InvalidValues
yield 'row-gap', tokens
yield 'column-gap', tokens
elif len(tokens) == 2:
column_gap, row_gap = gap(tokens[0:1]), gap(tokens[1:2])
if None in (column_gap, row_gap):
raise InvalidValues
yield 'row-gap', tokens[0:1]
yield 'column-gap', tokens[1:2]
else:
raise InvalidValues


@expander('grid-column-gap')
@generic_expander('column-gap')
def expand_legacy_column_gap(tokens, name):
"""Expand legacy ``grid-column-gap`` property."""
keyword = gap(tokens)
if keyword is None:
raise InvalidValues
column_gap, row_gap = gap(tokens[0:1]), gap(tokens[1:2])
if None in (column_gap, row_gap):
yield 'column-gap', tokens


@expander('grid-row-gap')
@generic_expander('row-gap')
def expand_legacy_row_gap(tokens, name):
"""Expand legacy ``grid-row-gap`` property."""
keyword = gap(tokens)
if keyword is None:
raise InvalidValues
yield 'row-gap', tokens[0:1]
yield 'column-gap', tokens[1:2]
yield 'row-gap', tokens


@expander('place-content')
Expand Down

0 comments on commit 41d735c

Please sign in to comment.