Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<script src="../../work-test.js"></script>
<style id="sheet">
@counter-style stars { system: cyclic; symbols: '*'; }
#list { display: list-item; list-style: stars inside; width: max-content; }
#generated { width: max-content; }
#generated::before { content: counter(c, stars); }
</style>
<div id="list"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>
<div id="generated"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></div>
<script>
// A counter style reaches the boxes built with it: the marker and the generated content rebuild.
// Their elements' children resolve no counter style, so the rebuild restyles none of them again.
test(() => {
const list = document.getElementById("list");
const generated = document.getElementById("generated");
internals.updateStyle();
const listWidth = list.getBoundingClientRect().width;
const generatedWidth = generated.getBoundingClientRect().width;
let markerRebuilt;
let generatedRebuilt;
const work = styleWork(() => {
document.getElementById("sheet").sheet.cssRules[0].symbols = "'++++'";
internals.updateStyle();
markerRebuilt = list.getBoundingClientRect().width > listWidth;
generatedRebuilt = generated.getBoundingClientRect().width > generatedWidth;
});
// FIXME: The change should restyle at most the two elements resolving the counter style, and none of
// their children (restyled: [list, generated]), but the style engine also restyles the children
// of #list, whose records name the counter-style registry through the list-style-type they inherit.
println(`restyled: [${work.restyled().map(shortStyleName).join(", ")}]`);
println(`rebuilding the boxes restyles nothing again: passes [${work.passes().join(", ")}]`);
println(`marker rebuilt: ${markerRebuilt}`);
println(`generated content rebuilt: ${generatedRebuilt}`);
});
</script>