Commit 214b78fb authored by Guillaume's avatar Guillaume

resolves #243 cascade styles

parent beaa5c8a
Pipeline #608 failed with stage
in 4 minutes and 15 seconds
<!DOCTYPE html PUBLIC>
<html lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<title>
Combined
</title>
<script src="../../../dist/paged.polyfill.js"></script>
<style>
@page {
size: A4;
background-color: #f6f5f5;
}
@media screen {
.pagedjs_page {
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}
}
</style>
<style>
@page {
size: A5;
background-color: #ffc9c9;
@bottom-center {
content: "Paged.js";
font-size: 0.8em;
font-weight: 800;
color: #973737;
}
}
h1 {
font-size: 40pt;
}
</style>
</head>
<body>
<section>
<h1>Lorem ipsum dolor sit amet</h1>
<p>
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.
</p>
<p>
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.
</p>
</section>
</body>
</html>
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);
});
}
});
...@@ -617,48 +617,41 @@ class AtPage extends Handler { ...@@ -617,48 +617,41 @@ class AtPage extends Handler {
addPageClasses(pages, ast, sheet) { addPageClasses(pages, ast, sheet) {
// First add * page // First add * page
if ("*" in pages && !pages["*"].added) { if ("*" in pages) {
let p = this.createPage(pages["*"], ast.children, sheet); let p = this.createPage(pages["*"], ast.children, sheet);
sheet.insertRule(p); sheet.insertRule(p);
pages["*"].added = true;
} }
// Add :left & :right // Add :left & :right
if (":left" in pages && !pages[":left"].added) { if (":left" in pages) {
let left = this.createPage(pages[":left"], ast.children, sheet); let left = this.createPage(pages[":left"], ast.children, sheet);
sheet.insertRule(left); 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); let right = this.createPage(pages[":right"], ast.children, sheet);
sheet.insertRule(right); sheet.insertRule(right);
pages[":right"].added = true;
} }
// Add :first & :blank // Add :first & :blank
if (":first" in pages && !pages[":first"].first) { if (":first" in pages) {
let first = this.createPage(pages[":first"], ast.children, sheet); let first = this.createPage(pages[":first"], ast.children, sheet);
sheet.insertRule(first); 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); let blank = this.createPage(pages[":blank"], ast.children, sheet);
sheet.insertRule(blank); sheet.insertRule(blank);
pages[":blank"].added = true;
} }
// Add nth pages // Add nth pages
for (let pg in 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); let nth = this.createPage(pages[pg], ast.children, sheet);
sheet.insertRule(nth); sheet.insertRule(nth);
pages[pg].added = true;
} }
} }
// Add named pages // Add named pages
for (let pg in 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); let named = this.createPage(pages[pg], ast.children, sheet);
sheet.insertRule(named); sheet.insertRule(named);
pages[pg].added = true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment