diff --git a/tests/draw/svg/test_shapes.py b/tests/draw/svg/test_shapes.py index 72c725765..a3a3a58b0 100644 --- a/tests/draw/svg/test_shapes.py +++ b/tests/draw/svg/test_shapes.py @@ -435,3 +435,26 @@ def test_rect_width_height_zero(assert_pixels): ''') + + +@assert_no_logs +def test_rect_fill_inherit(assert_pixels): + assert_pixels(''' + _________ + _________ + __KKKKK__ + __KKKKK__ + __KKKKK__ + __KKKKK__ + __KKKKK__ + _________ + _________ + ''', ''' + + + + + ''') diff --git a/weasyprint/svg/__init__.py b/weasyprint/svg/__init__.py index bff03a618..cb434bfed 100644 --- a/weasyprint/svg/__init__.py +++ b/weasyprint/svg/__init__.py @@ -150,9 +150,13 @@ def __iter__(self): child.attrib[key] = child.get('color', 'black') # Handle 'inherit' values - for key, value in child.attrib.items(): + for key, value in child.attrib.copy().items(): if value == 'inherit': - child.attrib[key] = self.get(key) + value = self.get(key) + if value is None: + del child.attrib[key] + else: + child.attrib[key] = value # Fix text in text tags if child.tag in ('text', 'textPath', 'a'):