Engineering / Field note
A rectangle does not prove a disclosure is open
Browser geometry, disclosure state and image readiness answer different questions. Five tested examples show how to keep those checks separate.
A browser check can find an image, measure a respectable rectangle and still be looking at content inside a closed disclosure. If the check equates width and height with visibility, it can demand a loaded picture before the user has opened its container. The useful repair is to record disclosure state, layout geometry and image readiness separately. Each answers a different question.
This is a documentation field note reviewed on November 29, 2026. The HTML Living Standard pages reviewed here were last updated November 27; the CSSOM View document identifies itself as an editor’s draft dated November 5. The examples are original synthetic browser fixtures, rather than a report of a new vulnerability or browser release. [1] [2] [3] [4]
Start with the control’s state
HTML defines details as a disclosure widget, with its first summary child providing the summary or legend. The open attribute controls whether the additional content is expanded. It is a boolean attribute: a present open attribute has an enabled state even when its text says false. Read the open property, and remove the attribute or assign false when the intention is to close it. [1]
The first example supplies its own tiny drawing, so there is no external image server, account or catalog involved. Its fixed dimensions make the geometry observation easy to reproduce. Keep this fixture small while investigating a checker; a complicated page adds several plausible explanations at once.
<!doctype html>
<meta charset="utf-8">
<title>Synthetic disclosure check</title>
<details id="sample">
<summary>Show sample drawing</summary>
<img id="drawing" width="96" height="48"
alt="Synthetic blue rectangle"
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='48'%3E%3Crect width='96' height='48' fill='steelblue'/%3E%3C/svg%3E">
</details>A rectangle has a narrower job
CSSOM View defines getBoundingClientRect through an element’s client rectangles. It describes a bounding box, rather than promising that a person can currently see the pixels. The HTML rendering guidance explains the disclosure-specific trap: closed details content uses content-visibility: hidden in an internal slot, and the specification explicitly notes that this choice affects layout-query APIs. [2] [3]
In our isolated check with headless Chromium 151.0.7922.34, the synthetic image retained a nonzero rectangle while its disclosure was closed. Opening it with the keyboard changed the disclosure and visibility signals. That observation belongs to this fixture and browser build. It gives a reproducible reason to reject the rectangle-only shortcut; it does not establish a compatibility result for every browser.
function readImageState(disclosure, image) {
const rect = image.getBoundingClientRect();
return {
disclosureOpen: disclosure.open,
hasNonzeroRectangle: rect.width > 0 && rect.height > 0,
width: rect.width,
height: rect.height,
resourceComplete: image.complete,
naturalWidth: image.naturalWidth
};
}Record these fields independently in a test result. A decoded resource can sit behind a closed control, while a correctly opened control can contain a resource that failed to decode. Rectangles are useful witnesses with a very narrow job description.
Check the surrounding disclosures
The nearest details element is not always the only relevant one. An inner disclosure may be open while an outer disclosure remains closed. The next helper walks light-DOM ancestors and preserves the first summary’s special role: the summary is the control the reader uses to reveal the other content. It is deliberately a disclosure-state helper, rather than a complete visibility engine.
function behindClosedDetails(element) {
for (let parent = element.parentElement;
parent; parent = parent.parentElement) {
if (!(parent instanceof HTMLDetailsElement) || parent.open) {
continue;
}
const summary = [...parent.children].find(
child => child.localName === "summary"
);
if (!summary || !summary.contains(element)) return true;
}
return false;
}For a component test, assert the initial open state, focus the summary and activate it through the keyboard, then assert the resulting state. Setting open directly exercises a different path. It is useful for preparing an image-readiness check, but it does not demonstrate that keyboard interaction works.
Keep visibility checks and image checks distinct
The CSSOM View draft also defines checkVisibility. Its checks include box existence and hidden content in ancestors, with options for opacity, CSS visibility and content skipped by content-visibility: auto. The helper below requests those extra checks and reports an unavailable API explicitly. A positive result still does not promise viewport intersection, freedom from an overlay or usable contrast. [3]
function visibilitySignal(element) {
if (typeof element.checkVisibility !== "function") {
return "unsupported";
}
return element.checkVisibility({
opacityProperty: true,
visibilityProperty: true,
contentVisibilityAuto: true
});
}For image readiness, decode provides a separate promise. The HTML image processing text distinguishes decoding from the process that presents content on screen. An image can therefore be ready as a resource without proving the surrounding interface has exposed it to the reader. [4]
async function inspectExpandedImage(disclosure, image) {
const initiallyOpen = disclosure.open;
try {
disclosure.open = true;
if (behindClosedDetails(image)) {
throw new Error("Another disclosure remains closed");
}
await image.decode();
await new Promise(resolve => requestAnimationFrame(
() => requestAnimationFrame(resolve)
));
return {
decoded: true,
potentialVisibility: visibilitySignal(image)
};
} finally {
disclosure.open = initiallyOpen;
}
}The final helper uses the functions from examples three and four. It opens this ungrouped fixture, refuses a still-closed outer disclosure, awaits decoding, allows two animation frames before sampling visibility, and restores the original open state even if decoding fails. A complex accordion needs restoration of every affected control, since opening one named group member can close another. Those frames give rendering an opportunity to progress; they are not a general promise that an application has settled. [1]
Keep the remaining acceptance work observable: exercise both collapsed and expanded states, confirm image readiness after expansion, inspect the resulting pixels, and check keyboard behavior independently. Include hidden, transparent, nested and broken-image controls so a convenient measurement cannot quietly become the whole verdict. These small distinctions make failures easier to diagnose and successful checks easier to trust.
Sources + further reading
Source dates describe the original material. Publication above is the date this Zyel article went live.
- HTML Living Standard — The details elementWHATWG · Checked Nov 29, 2026
- HTML Living Standard — Rendering details and summaryWHATWG · Checked Nov 29, 2026
- CSSOM View Module Level 1 — Element geometry and checkVisibilityW3C CSS Working Group · Checked Nov 29, 2026
- HTML Living Standard — Image decoding and presentationWHATWG · Checked Nov 29, 2026
Reader discussion
What would you ask next?
Questions, useful corrections and thoughtful disagreement are welcome. Comments are reviewed before they appear.
No reader comments yet.