diff --git a/tests/test_target.py b/tests/test_target.py index f0e6d4e617..65db410a6b 100644 --- a/tests/test_target.py +++ b/tests/test_target.py @@ -157,3 +157,28 @@ def test_target_float(): text_box, after = inline.children assert text_box.text == 'link' assert after.children[0].children[0].text == '1' + + +@assert_no_logs +def test_target_absolute(): + document = FakeHTML(string=''' + +
link
+

abc

+ ''') + page, = document.render().pages + html, = page._page_box.children + body, = html.children + div, h1 = body.children + line, = div.children + inline, = line.children + text_box, after = inline.children + assert text_box.text == 'link' + assert after.children[0].text == '1' diff --git a/weasyprint/layout/page.py b/weasyprint/layout/page.py index bd9bf8b8dd..1f83630bfe 100644 --- a/weasyprint/layout/page.py +++ b/weasyprint/layout/page.py @@ -1,6 +1,7 @@ """Layout for pages and CSS3 margin boxes.""" import copy +from itertools import chain from math import inf from ..css import PageType, computed_from_cascaded @@ -605,7 +606,9 @@ def make_page(context, root_box, page_type, resume_at, page_number, context.finish_block_formatting_context(root_box) page.children = [root_box, footnote_area] - descendants = page.descendants() + descendants = chain(page.descendants(), *( + child.descendants() if hasattr(child, 'descendants') else (child,) + for child in positioned_boxes)) # Update page counter values _standardize_page_based_counters(style, None)