Truly independent web browser
<!DOCTYPE html>
<script src="../../include.js"></script>
<style>
.item::before { content: "x"; color: rgb(1, 2, 3); }
.attribute .item::before { color: attr(data-color type(<color>)); }
</style>
<div id="parent"><span class="item" id="first" data-color="green"></span><span class="item" id="second" data-color="purple"></span></div>
<script>
// A pseudo-element's attr() substitutes its originating element's attributes: two
// pseudo-elements alike in everything else take their own values, and an attribute change
// reaches the pseudo-element.
test(() => {
const color = element => getComputedStyle(element, "::before").color;
internals.updateStyle();
document.getElementById("parent").classList.add("attribute");
internals.updateStyle();
println(`colors: ${color(first)} ${color(second)}`);
first.dataset.color = "red";
internals.updateStyle();
println(`colors: ${color(first)} ${color(second)}`);
});
</script>