Truly independent web browser
<!DOCTYPE html>
<script src="../include.js"></script>
<style>
.container { background-color: rgb(20, 20, 20); }
.container.to { background-color: rgb(220, 220, 220); }
.container.how { transition: background-color 1000s linear 0s; }
.transition { background-color: inherit; }
.transition.how { transition: background-color 1000s linear 0s; }
</style>
<div class="container"><div class="transition">Text sample</div></div>
<script>
// https://drafts.csswg.org/css-transitions-1/#after-change-style
// `background-color` is not an inherited property, but the child reads it through an explicit
// `inherit`, so its after-change style still inherits the parent's after-change value.
// No rule matching the child changes here, so the child only observes the change if the
// parent's style diff propagates it, and it then starts exactly one transition of its own.
test(() => {
const container = document.querySelector(".container");
const child = document.querySelector(".transition");
println("container before: " + getComputedStyle(container).backgroundColor);
println("child before: " + getComputedStyle(child).backgroundColor);
container.classList.add("how");
child.classList.add("how");
internals.updateStyle();
container.classList.add("to");
internals.updateStyle();
const containerTransition = container.getAnimations().find(animation => animation instanceof CSSTransition);
const childTransition = child.getAnimations().find(animation => animation instanceof CSSTransition);
println("container started one transition: " + (container.getAnimations().length === 1));
println("child started one transition: " + (child.getAnimations().length === 1));
println("child transition property: " + childTransition.transitionProperty);
containerTransition.currentTime = 500000;
childTransition.currentTime = 500000;
internals.updateStyle();
println("child transition survived resampling: " + (child.getAnimations()[0] === childTransition));
println("container and child midpoints match: "
+ (getComputedStyle(container).backgroundColor === getComputedStyle(child).backgroundColor));
containerTransition.currentTime = 1000000;
childTransition.currentTime = 1000000;
println("container after: " + getComputedStyle(container).backgroundColor);
println("child after: " + getComputedStyle(child).backgroundColor);
});
</script>