mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 16:07:57 +03:00
Bug fix: expand shorthands in style attributes too.
This commit is contained in:
parent
71947abded
commit
6594f8e9a1
@ -318,7 +318,9 @@ def handle_style_attribute(element):
|
||||
# TODO: no href for parseStyle. What about relative URLs?
|
||||
# CSS3 says we should resolve relative to the attribute:
|
||||
# http://www.w3.org/TR/css-style-attr/#interpret
|
||||
for prop in parseStyle(style_attribute):
|
||||
declaration = parseStyle(style_attribute)
|
||||
declaration = shorthands.expand_shorthands_in_declaration(declaration)
|
||||
for prop in declaration:
|
||||
precedence = (
|
||||
declaration_precedence('author', prop.priority),
|
||||
# 1 for being a style attribute, 0 as there is no selector.
|
||||
|
@ -137,5 +137,3 @@ def expand_shorthands_in_declaration(style):
|
||||
else:
|
||||
new_style.setProperty(prop)
|
||||
return new_style
|
||||
|
||||
|
||||
|
@ -21,8 +21,7 @@
|
||||
<h1>WeasyPrint test document</h1>
|
||||
<p style="color: black; font-size: 2em">Hello</p>
|
||||
<ul>
|
||||
<li><a href=home.html>Home</a>
|
||||
<li><a href=home.html style="padding: 1px 2px 3px 4px">Home</a>
|
||||
<li>…
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
|
@ -123,6 +123,10 @@ def test_annotate_document():
|
||||
|
||||
color = a.style['color'][0]
|
||||
assert (color.red, color.green, color.blue, color.alpha) == (255, 0, 0, 1)
|
||||
assert a.style.padding_top == 1
|
||||
assert a.style.padding_right == 2
|
||||
assert a.style.padding_bottom == 3
|
||||
assert a.style.padding_left == 4
|
||||
|
||||
# The href attr should be as in the source, not made absolute.
|
||||
assert ''.join(v.value for v in after.style['content']) == ' [home.html]'
|
||||
@ -180,4 +184,3 @@ def test_page():
|
||||
with attest.raises(ValueError) as exc:
|
||||
css.annotate_document(document, user_stylesheets=[user_sheet_with_em])
|
||||
assert exc.args[0] == 'The em unit is not allowed in a page context.'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user