Skip to content

The design language that makes your AI harness better at design.

JavaScript

Hidden media no longer exempts a card from nested-cards

Paul Bakausc4b40684a3a2
diff --git a/crates/html/src/page.rs b/crates/html/src/page.rs
index 59b9b260f..bec603aa8 100644
--- a/crates/html/src/page.rs
+++ b/crates/html/src/page.rs
@@ -274,7 +274,12 @@ fn controls_in<'a>(el: &StaticElement<'a>) -> Vec<(StaticElement<'a>, Control, S
/// control but its own chrome (a copy button, an icon button).
fn frames_embedded_content(el: &StaticElement<'_>, outer: &StaticElement<'_>) -> bool {
let controls = controls_in(el);
- let player_media = el.query_selector("audio[controls], video[controls]").is_some();
+ // Media the cascade hides (`hidden`, `display: none`) shows no player,
+ // as the URL engine, which needs the player's box, also finds.
+ let player_media = el
+ .query_selector_all("audio[controls], video[controls]")
+ .iter()
+ .any(is_rendered_type_element);
let custom_player = controls
.iter()
.any(|(_, kind, name)| *kind == Control::Button && is_play_name(name))
diff --git a/crates/html/tests/nested_cards_embedded.rs b/crates/html/tests/nested_cards_embedded.rs
index 2923ef81c..9c7b1d51c 100644
--- a/crates/html/tests/nested_cards_embedded.rs
+++ b/crates/html/tests/nested_cards_embedded.rs
@@ -129,6 +129,9 @@ fn embedded_content_beside_ordinary_controls_still_reports() {
for inner in [
// A settings panel holding a hidden sound element.
"<div class=\"border rounded-xl\"><audio preload=\"none\"></audio><p>Email me when a scan finishes, with a summary.</p><button>Save</button> <button>Cancel</button></div>",
+ // A player the page hides is not the box's content.
+ "<div class=\"border rounded-xl\"><audio controls hidden src=\"a.mp3\"></audio><p>Sample audio</p></div>",
+ "<div class=\"border rounded-xl\"><video controls style=\"display: none\"></video><p>Sample clip</p></div>",
// A profile card with a small avatar video.
"<div class=\"border rounded-xl\"><video width=\"48\" height=\"48\" muted></video><p>Jane Doe, head of design, writes about type.</p><button>Follow</button></div>",
// A pricing tier with a promo's play button and a progress bar.