Skip to content

Commit 30cbeb6

Browse files
test(css): insert the cascade probe's root once both sheets are adopted
Reinserting the root before each read reloaded replaced elements between the reads, so Firefox laid the document out at different heights for one sheet. Building the tree detached and inserting it after the adoptions styles the root afresh, which is what WebKit needed, and leaves the reads one layout.
1 parent c37200b commit 30cbeb6

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

‎test/helpers/syntaxEquivalence.js‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,10 +2199,10 @@ const compareCascades = ({ pairs, types }) => {
21992199
return sheet;
22002200
};
22012201
const root = document.createElement("div");
2202-
document.body.append(root);
22032202
/** @type {CascadeReport[]} */
22042203
const reports = [];
22052204
for (const pair of pairs) {
2205+
root.remove();
22062206
root.textContent = "";
22072207
const afterRules = inventory(adopt(pair.after).cssRules, "", new Map());
22082208
const beforeRules = inventory(adopt(pair.before).cssRules, "", new Map());
@@ -2306,20 +2306,14 @@ const compareCascades = ({ pairs, types }) => {
23062306
}
23072307
return out;
23082308
};
2309-
/**
2310-
* Reinsert the root so its subtree is styled afresh under the current sheet.
2311-
* WebKit can otherwise keep a value the root inherited under an earlier one.
2312-
*/
2313-
const restyle = () => {
2314-
root.remove();
2315-
document.body.append(root);
2316-
};
2317-
restyle();
2309+
// Inserted only once both sheets are adopted: WebKit kept what a root
2310+
// already in the document inherited before, and reinserting between reads
2311+
// would reload what a replaced element shows.
2312+
document.body.append(root);
23182313
// Layout first: an `<object>` settles what it renders as only once one runs.
23192314
const renderedBefore = rendered();
23202315
const before = read();
23212316
adopt(pair.after);
2322-
restyle();
23232317
const renderedAfter = rendered();
23242318
const after = read();
23252319
/** @type {string[]} */

0 commit comments

Comments
 (0)