Skip to content

Commit

Permalink
Don’t copy the already-cascaded style when copying nodes
Browse files Browse the repository at this point in the history
Fix #1370.
  • Loading branch information
liZe committed Jun 1, 2021
1 parent edf47f5 commit 41d4a26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
10 changes: 3 additions & 7 deletions weasyprint/svg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,14 @@ def __init__(self, wrapper, style):
self._etree_node = wrapper.etree_element
self._style = style

self.attrib = wrapper.etree_element.attrib
self.attrib = wrapper.etree_element.attrib.copy()

self.vertices = []
self.bounding_box = None

def copy(self):
"""Create a deep copy of the node."""
copy = Node(self._wrapper, self._style)
copy.attrib = self.attrib.copy()
copy.vertices = self.vertices.copy()
copy.bounding_box = None
return copy
"""Create a deep copy of the node as it was when first created."""
return Node(self._wrapper, self._style)

def get(self, key, default=None):
"""Get attribute."""
Expand Down
3 changes: 1 addition & 2 deletions weasyprint/svg/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def use(svg, node, font_size):

parsed_url = parse_url(node.get_href())
if parsed_url.fragment and not parsed_url.path:
tree = svg.tree.get_child(parsed_url.fragment)
tree = svg.tree.get_child(parsed_url.fragment).copy()
else:
url = parsed_url.geturl()
try:
Expand All @@ -39,7 +39,6 @@ def use(svg, node, font_size):
else:
use_svg.get_intrinsic_size(font_size)
tree = use_svg.tree
tree = tree.copy()

if tree.tag in ('svg', 'symbol'):
# Explicitely specified
Expand Down

0 comments on commit 41d4a26

Please sign in to comment.