Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
:root {
--spacing: 7px;
}
.item {
padding-left: var(--spacing);
}
</style>
<div id="host"></div>
<script>
test(() => {
internals.updateStyle();
const host = document.getElementById("host");
for (let index = 0; index < 50; ++index) {
const item = document.createElement("div");
item.className = "item";
// Keep record sharing from hiding repeated substitution while leaving every item on
// the same inherited custom-property environment.
item.style.zIndex = index;
host.appendChild(item);
}
internals.updateStyle();
println(`shared value: ${getComputedStyle(host.lastElementChild).paddingLeft}`);
host.lastElementChild.style.zIndex = 100;
internals.updateStyle();
println(`later transaction value: ${getComputedStyle(host.lastElementChild).paddingLeft}`);
// A moved environment gives every item the new value.
document.styleSheets[0].cssRules[0].style.setProperty("--spacing", "9px");
internals.updateStyle();
println(`moved value: ${getComputedStyle(host.firstElementChild).paddingLeft}`);
println(`moved neighbour: ${getComputedStyle(host.lastElementChild).paddingLeft}`);
});
</script>