Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
.origin + .adjacent { color: rgb(0, 128, 0) }
.origin ~ .following { color: rgb(0, 0, 255) }
</style>
<div id="fixture">
<div id="parent">
<span id="origin" class="origin"></span>
<span id="adjacent" class="adjacent"></span>
<span id="following" class="following"></span>
</div>
<div id="elsewhere"></div>
</div>
<script>
// A sibling selector is routed from the element its left compound names. One transaction can
// both move that element and take the feature away, and by routing time the facts only describe
// where it ended up carrying what it ended up with. The siblings it left behind still have to be
// told, so the route has to be found from what the element is losing as much as from what it
// still has.
let forced = 0;
function snapshot() {
return Array.from(document.querySelectorAll("#fixture *"))
.map(element => `${element.id}=${getComputedStyle(element).color}`)
.join(" ");
}
function settlesExactly(name, mutate) {
internals.updateStyle();
mutate();
internals.updateStyle();
const incremental = snapshot();
CSS.registerProperty({ name: `--force-${forced++}`, syntax: "*", inherits: false, initialValue: "1px" });
internals.updateStyle();
const complete = snapshot();
if (incremental === complete) {
println(`${name}: settles exactly`);
return;
}
println(`${name}: STALE`);
println(` incremental: ${incremental}`);
println(` complete: ${complete}`);
}
test(() => {
const parent = document.getElementById("parent");
const elsewhere = document.getElementById("elsewhere");
const origin = document.getElementById("origin");
settlesExactly("the origin loses its feature as it leaves the sequence", () => {
origin.classList.remove("origin");
elsewhere.appendChild(origin);
});
settlesExactly("it comes back carrying the feature again", () => {
origin.classList.add("origin");
parent.insertBefore(origin, parent.firstChild);
});
settlesExactly("it loses the feature while staying and moving within the sequence", () => {
origin.classList.remove("origin");
parent.appendChild(origin);
});
});
</script>