Skip to content

core: skip non-summary children of a closed <details> in innerText - #269

Open
Jackzigen wants to merge 1 commit into
cloudflare:mainfrom
Jackzigen:fix/inner-text-closed-details
Open

Jackzigen wants to merge 1 commit into
cloudflare:mainfrom
Jackzigen:fix/inner-text-closed-details

Conversation

@Jackzigen

Copy link
Copy Markdown

Fixes the closed <details> half of #262.

What

innerText on a closed <details> leaked its bare-text body:

<details><summary>sum</summary>CLOSEDDETAILS</details>

read "sum\nCLOSEDDETAILS" where Chrome reads "sum". The <p>-body shape in the issue was already correct.

Why

A closed <details> renders only its first <summary> child. The default stylesheet hides the element children through

details:not([open]) > :not(summary:first-of-type) { display: none !important; }

which matches element children only. A bare text node has no box of its own — collect_children emits it whenever the inherited ctx.visible is true, and it inherits visibility from <details> itself.

Fix

In collect_children, when the node is a <details> without the open attribute, skip every child except the first <summary>. This covers:

  • bare text after the summary (the repro)
  • bare text before the summary
  • a second <summary>
  • the ancestor case, where <details> sits inside the queried element

open details are untouched.

Verification

  • cargo test --lib inner_text — 17 passed (3 new)
  • cargo test --lib (full kitesurf-core host suite) — 1093 passed, 0 failed
  • cargo fmt --check clean; cargo clippy --lib reports nothing on inner_text.rs

Not addressed here: the content-visibility: hidden half of #262. That depends on whether the stylo gate should be lifted, which is a separate decision.

A closed <details> renders only its first <summary> child. The default
stylesheet hides the element children with `display:none`, but a bare
text node has no box of its own: it inherits visibility from <details>,
so collect_children emitted it and innerText read "sum\nCLOSEDDETAILS"
where Chrome reads "sum".

Skip every child after the first <summary> when <details> lacks the open
attribute. Covers text before the summary, a second <summary>, and the
ancestor case where <details> sits inside the queried element.

Signed-off-by: Jackzigen <jackzigen@users.noreply.github.com>
@github-actions github-actions Bot added the vouch:unvouched Author is not vouched; CI waits for a maintainer. label Nov 29, 2026
@github-actions

Copy link
Copy Markdown

Hi @Jackzigen. Thanks for your interest in Kitesurf!

Your pull request is open, but your GitHub username is not on the vouched
contributor list yet. CI does not run for an unvouched pull request until a
maintainer adds the ci:approved label, so a red or missing CI check is
expected while you wait. A maintainer will review the change and can approve CI
or vouch for you.

An unvouched pull request is closed after 14 days of inactivity.

To become vouched, discuss the bug, use case, or proposed fix in a
Kitesurf issue and link this
pull request from the issue. A maintainer can add your username to
.github/VOUCHED.td in a pull request. After that merges, the
ci:approved label is no longer needed, but a maintainer still approves the CI
runs of a pull request from a fork. Comment /recheck-vouch to refresh the
trust label. Vouching does not approve any code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

vouch:unvouched Author is not vouched; CI waits for a maintainer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant