A page measured in a hidden browser tab can hold both sides of an unfinished transition, and a first-match query reads the outgoing one
Browsers throttle or pause animation frames and transition events in a tab whose document is hidden. A component that animates between two states (a sliding calendar month, a carousel, a route transition) typically mounts the incoming view before unmounting the outgoing one, and removes the old view only when the transition ends. In a hidden tab that end can be delayed indefinitely, so the DOM keeps both views at once. A measurement script that locates elements by text, by the first match in document order, or by "the element of this kind" then reads whichever view comes first, which is usually the outgoing one, and reports stale positions and states as current.
Resurfaces when
- about to measure or compare a page's layout through a background tab driven over a debugging protocol
- about to click a control that animates to a new view and read the result straight after, without the tab in front
- a measured page still reports the previous month, slide or step after a click that visibly should have changed it
- a dump of one panel contains two copies of the same grid or list, one offset sideways
The lesson’s retrieval contract, weighted three times heavier than its body. A lesson that states when it applies doesn’t need a semantic search to find it.
The lesson
A hidden browser tab is not a slower version of a visible one. Animation frames and transition-end events are throttled or held back there, so any view that swaps by animation can sit half-swapped for as long as the tab stays hidden. Both the old and the new content are in the DOM at the same time, with the new one usually off to the side, waiting to slide in.
Nothing reports this. A query by visible text, querySelector, or "the first table inside the panel" returns a real element with real computed style and a real box. It is just the wrong one. The numbers look plausible because they are the true numbers for the state the page has just left.
The failure that taught it
A parity pass compared a booking calendar on a reference site with its reimplementation, both open in background tabs of the user's browser so the user's own window was never disturbed. The script pressed the reference calendar's "jump to the earliest available date" link and then read the grid. The month title it found was still the old month, and the day cells it read were the old month's. The new month's table was in the DOM too, positioned outside the panel's horizontal bounds, because the slide transition had never finished in the hidden tab. A title search found the old month's title first. A filter on "x inside the panel" was what exposed the second table.
How to apply it
- Before measuring after any state change in a background tab, read
document.visibilityState. If it ishidden, assume transitions may not finish. - Select the view you mean by geometry and state together: the element whose box lies inside the container's bounds, or the one without the leaving or entering transition class. Not by first match.
- After a change, wait for a condition on the new state (the expected title text present, and exactly one grid in the container), not for a fixed delay.
- If a transition must finish, disable it for the measurement (inject a style that sets transition and animation durations to zero) or bring the tab forward when the user allows it. Then say which one you did, because forcing it changes what was measured.
- Treat any dump in which a single panel holds two copies of a grid as a measurement defect to resolve, not as data.
Where this claim comes from
- Lesson
A page measured in a hidden browser tab can hold both sides of an unfinished transition, and a first-match query reads the outgoing one
- Distillationmechanism stated
Written from the mechanism, not the incident — which is what lets it transfer to code sharing nothing with the original.
- Scar1 occurrence
One recorded failure — weaker evidence, and ranked accordingly rather than presented as settled.
- Evidencenone recorded
No source records recorded — hand-written and migrated lessons predate the pipeline that captures them.
What happened when it was used
- 7
- retrieved
- 3
- acted on
- 2
- held up
- 0
- did not hold up
Applied 3 times. Outcomes move the ranking both ways, which is what makes this improve rather than just grow.