Skip to content

Treat closed <details> non-summary descendants as non-visible#317

Merged
route merged 1 commit into
rubycdp:mainfrom
myabc:feature/details-visibility
Jul 9, 2026
Merged

Treat closed <details> non-summary descendants as non-visible#317
route merged 1 commit into
rubycdp:mainfrom
myabc:feature/details-visibility

Conversation

@myabc

@myabc myabc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What

Treats non-summary descendants of a closed <details> element as non-visible, un-skipping 2 Capybara #visible? shared specs.

Why

_cuprite.isVisible walked the ancestor chain checking only display:none / visibility:hidden / opacity:0. A closed <details> hides its non-summary children via the rendering model, not computed display — so getComputedStyle(child).display is block and those children were reported visible.

How

In the isVisible ancestor walk: if a node's parent is a <details> without [open] and the node is not that details' first <summary>, return false.

  • Deep descendants are caught as the walk ascends to the direct child of the <details>.
  • The first <summary> (and its subtree) stays visible; a second <summary> is correctly hidden.
  • Open details are unaffected (!parent.open short-circuits); toggling reads the live .open state.

Testing

  • The 2 previously-skipped specs now pass (details non-summary descendants should be non-visible when closed, works when details is toggled open and closed), alongside the already-passing closed-summary-visible and open-details-visible specs.
  • Regression: 58 #visible? / visibility examples, 0 failures.
  • bundle exec rubocop clean.

Part of #307.

🤖 Authored with agent assistance.

Copilot AI review requested due to automatic review settings July 9, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Cuprite’s client-side visibility detection to match the HTML rendering model for closed <details> elements, allowing previously-skipped Capybara #visible? shared specs to run and pass.

Changes:

  • Update _cuprite.isVisible to treat non-<summary> descendants of a closed <details> as not visible.
  • Unskip two Capybara #visible? shared specs in spec/spec_helper.rb that are now expected to pass.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
spec/spec_helper.rb Removes two #visible? examples from the skip list now that the driver behavior matches expectations.
lib/capybara/cuprite/javascripts/index.js Enhances ancestor-walk visibility logic to account for closed <details> hiding non-summary content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@route route merged commit b64f03d into rubycdp:main Jul 9, 2026
7 checks passed
@route

route commented Jul 9, 2026

Copy link
Copy Markdown
Member

Thank you!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants