diff --git a/specs/page-rules/combined/__image_snapshots_linux__/combined-spec-js-combined-should-create-a-pdf-1-snap.png b/specs/page-rules/combined/__image_snapshots_linux__/combined-spec-js-combined-should-create-a-pdf-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..cfcfbbce77a5e59b116d95f01e6116a1b070ad7a Binary files /dev/null and b/specs/page-rules/combined/__image_snapshots_linux__/combined-spec-js-combined-should-create-a-pdf-1-snap.png differ diff --git a/specs/page-rules/combined/combined.html b/specs/page-rules/combined/combined.html new file mode 100644 index 0000000000000000000000000000000000000000..16e0e7d881b9cfb26f80a7bfb345951900b7b881 --- /dev/null +++ b/specs/page-rules/combined/combined.html @@ -0,0 +1,56 @@ + + + + + + + Combined + + + + + + +
+

Lorem ipsum dolor sit amet

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi non suscipit odio. Aenean ut ligula id mauris efficitur tincidunt vitae non leo. In convallis convallis leo, eget + molestie metus imperdiet eu. Praesent pharetra, leo a laoreet mattis, ligula nisl commodo ante, non vestibulum nisi lacus eget magna. Maecenas scelerisque nibh ac felis + egestas, egestas elementum risus pellentesque. Nulla iaculis ut leo a iaculis. Donec vel sodales dolor, vel fringilla elit. Vivamus aliquam diam eu maximus elementum. Integer + eu urna at felis fermentum hendrerit. +

+

+ Nulla dignissim pellentesque magna ac maximus. Integer id tincidunt erat. Sed elementum posuere augue, quis pharetra mi vehicula in. Nullam rhoncus mi quis lectus gravida + dignissim. Pellentesque a tortor ut leo pretium auctor non in massa. Nunc efficitur vestibulum mi, id mattis quam aliquet id. Ut semper tortor sit amet molestie mattis. + Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. +

+
+ + diff --git a/specs/page-rules/combined/combined.spec.js b/specs/page-rules/combined/combined.spec.js new file mode 100644 index 0000000000000000000000000000000000000000..7c4a86f0ae70744efe3057add665f82929773581 --- /dev/null +++ b/specs/page-rules/combined/combined.spec.js @@ -0,0 +1,30 @@ +const TIMEOUT = 10000; + +describe("combined", () => { + let page; + beforeAll(async () => { + page = await loadPage("page-rules/combined/combined.html"); + return page.rendered; + }, TIMEOUT); + + afterAll(async () => { + if (!DEBUG) { + await page.close(); + } + }); + + it("should render 1 page", async () => { + let pages = await page.$$eval(".pagedjs_page", (r) => { + return r.length; + }); + expect(pages).toEqual(1); + }); + + if (!DEBUG) { + it("should create a pdf", async () => { + let pdf = await page.pdf(PDF_SETTINGS); + + expect(pdf).toMatchPDFSnapshot(1); + }); + } +}); diff --git a/src/modules/paged-media/atpage.js b/src/modules/paged-media/atpage.js index b01dab8d9259be5023cd13fb10d03a0033d3455f..4934b1541ec4896ea714ef00864d7f7e1f2ef63f 100644 --- a/src/modules/paged-media/atpage.js +++ b/src/modules/paged-media/atpage.js @@ -617,48 +617,41 @@ class AtPage extends Handler { addPageClasses(pages, ast, sheet) { // First add * page - if ("*" in pages && !pages["*"].added) { + if ("*" in pages) { let p = this.createPage(pages["*"], ast.children, sheet); sheet.insertRule(p); - pages["*"].added = true; } // Add :left & :right - if (":left" in pages && !pages[":left"].added) { + if (":left" in pages) { let left = this.createPage(pages[":left"], ast.children, sheet); sheet.insertRule(left); - pages[":left"].added = true; } - if (":right" in pages && !pages[":right"].added) { + if (":right" in pages) { let right = this.createPage(pages[":right"], ast.children, sheet); sheet.insertRule(right); - pages[":right"].added = true; } // Add :first & :blank - if (":first" in pages && !pages[":first"].first) { + if (":first" in pages) { let first = this.createPage(pages[":first"], ast.children, sheet); sheet.insertRule(first); - pages[":first"].added = true; } - if (":blank" in pages && !pages[":blank"].added) { + if (":blank" in pages) { let blank = this.createPage(pages[":blank"], ast.children, sheet); sheet.insertRule(blank); - pages[":blank"].added = true; } // Add nth pages for (let pg in pages) { - if (pages[pg].nth && !pages[pg].added) { + if (pages[pg].nth) { let nth = this.createPage(pages[pg], ast.children, sheet); sheet.insertRule(nth); - pages[pg].added = true; } } // Add named pages for (let pg in pages) { - if (pages[pg].name && !pages[pg].added) { + if (pages[pg].name) { let named = this.createPage(pages[pg], ast.children, sheet); sheet.insertRule(named); - pages[pg].added = true; } } @@ -747,7 +740,7 @@ class AtPage extends Handler { } }); list.append(bVar, item); - } + } } }