From ffde012d749aa4e3a9f4cb5aa9b892e73ae6e678 Mon Sep 17 00:00:00 2001 From: Alexander Brandon Coles Date: Thu, 9 Jul 2026 20:34:12 +0100 Subject: [PATCH] Treat closed
non-summary descendants as non-visible --- lib/capybara/cuprite/javascripts/index.js | 11 ++++++++++- spec/spec_helper.rb | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/capybara/cuprite/javascripts/index.js b/lib/capybara/cuprite/javascripts/index.js index 837ee78..9a76e0c 100644 --- a/lib/capybara/cuprite/javascripts/index.js +++ b/lib/capybara/cuprite/javascripts/index.js @@ -85,7 +85,16 @@ class Cuprite { if (style.display === "none" || style.visibility === "hidden" || parseFloat(style.opacity) === 0) { return false; } - node = node.parentElement ?? (node.getRootNode() instanceof ShadowRoot && node.getRootNode()); + + let parent = node.parentElement; + if (parent && parent.tagName === "DETAILS" && !parent.open) { + // In a closed
only the first (and its subtree) is rendered. + if (node !== parent.querySelector(":scope > summary")) { + return false; + } + } + + node = parent ?? (node.getRootNode() instanceof ShadowRoot && node.getRootNode()); } } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b7ebf23..23e00a7 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -56,8 +56,6 @@ module TestSessions node Element#drop can drop strings node Element#drop can drop multiple strings node Element#drop can drop a pathname - node #visible? details non-summary descendants should be non-visible - node #visible? works when details is toggled open and closed node #set should submit single text input forms if ended with node #shadow_root should produce error messages when failing #has_field with valid should be false if field is invalid