refactor: remove exact cross-layer css duplicates

This commit is contained in:
leefer
2026-08-02 11:54:00 +08:00
parent db9ca5c676
commit b0c0e82f2d
7 changed files with 70 additions and 26 deletions
+24
View File
@@ -1803,6 +1803,30 @@ test("heart breathing prepares once then contracts on each exhale", async ({ pag
await expect(page.locator(".heart-breath-ripple span").first()).toHaveCSS("transition-duration", "4s");
});
test("stylesheet layers do not repeat identical top-level rules", async ({ page }) => {
await mockApplication(page, session("admin", true));
await page.goto("/index.html");
const duplicates = await page.evaluate(() => {
const occurrences = new Map();
for (const sheet of Array.from(document.styleSheets)) {
const href = sheet.href ? new URL(sheet.href).pathname : "inline";
for (const rule of Array.from(sheet.cssRules || [])) {
if (typeof rule.selectorText !== "string" || !rule.style) continue;
const key = `${rule.selectorText}\u0000${rule.style.cssText}`;
const rows = occurrences.get(key) || [];
rows.push(href);
occurrences.set(key, rows);
}
}
return Array.from(occurrences.entries())
.filter(([, paths]) => new Set(paths).size > 1)
.map(([rule, paths]) => ({ rule, paths }));
});
expect(duplicates).toEqual([]);
});
test("mobile shell stays within the viewport", async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await mockApplication(page, session("user", true));