From 65b9707363f69f653d5acc15643e951e8300d89e Mon Sep 17 00:00:00 2001 From: lanyue-llk <270302213+lanyue-llk@users.noreply.github.com> Date: Thu, 12 Nov 2026 16:33:16 +0700 Subject: [PATCH 1/2] fix(dump): keep media sources and sanitized range/color values in markdown --- .../src/runtime/markdown_dump/visibility.rs | 19 +++++++++++++++++-- .../runtime/page_vm/tests/markdown_dump.rs | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs b/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs index 7d41467c09b..5718d807580 100644 --- a/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs +++ b/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs @@ -168,8 +168,11 @@ impl<'a, D: MarkdownSource> MarkdownDom<'a, D> { // A clean textarea gets its default from child text, not the // control-state slot (which is initially empty). Once dirty, // even an empty live value is authoritative. + // Range and color always sanitize a value; export it only when + // the author supplied one, as the sanitized `.value` reports. let authored_control = - matches!(element.input_type(), InputType::Range | InputType::Color); + matches!(element.input_type(), InputType::Range | InputType::Color) + && element.attribute("value").is_none_or(str::is_empty); if (element.is_html_input() && !authored_control) || element.input_value_dirty() { attribute_overrides .entry(node) @@ -235,8 +238,20 @@ impl<'a, D: MarkdownSource> MarkdownDom<'a, D> { Dom::node_kind(dom, node), NodeKind::Element("tr" | "thead" | "tbody" | "tfoot") ); + // The UA sheet hides , but its media element still uses it. + let media_source = matches!(Dom::node_kind(dom, node), NodeKind::Element("source")) + && dom.parent_node(node).is_some_and(|parent| { + matches!( + Dom::node_kind(dom, parent), + NodeKind::Element("video" | "audio") + ) + }); if collapsed_table_part - || (values.display == "none" && !in_source && !disclosure_root && !disclosure_path) + || (values.display == "none" + && !in_source + && !media_source + && !disclosure_root + && !disclosure_path) || (parent_is_disclosure_path && !disclosure_root && !disclosure_path) || dom.parent_node(node).is_some_and(|parent| { suppressed.contains(&parent) || hidden_contents.contains(&parent) diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs b/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs index c5c37ba15a6..db914107a43 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs @@ -581,7 +581,9 @@ async fn markdown_live_structure_and_visibility_have_exact_outputs() { ("

Hi

", "# Hi"), ("12", "12"), (" ", "Volume"), - (" ", "abc invalid"), + (" ", "50 #000000"), + (" ", "Volume 100 #ff0000"), + ("", "[Video](https://example.test/a.webm) [Video](https://example.test/a.mp4)\n\n[Audio](https://example.test/b.ogg)"), ("
AB
", "A\n\nB"), ("

AB

", "A\n\nB"), ("Active Reviewed", "Active Reviewed"), From ac77917e4eb0717509f22d96125a7e3c1b50b3a7 Mon Sep 17 00:00:00 2001 From: lanyue-llk <270302213+lanyue-llk@users.noreply.github.com> Date: Thu, 12 Nov 2026 17:47:47 +0700 Subject: [PATCH 2/2] fix(style): stop hiding source elements in the UA sheet --- .../src/runtime/markdown_dump/visibility.rs | 14 +------------- .../src/runtime/page_vm/tests/markdown_dump.rs | 1 + moli-renderer-v8/src/style_engine/ua/html.css | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs b/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs index 5718d807580..aabbcfacc6d 100644 --- a/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs +++ b/moli-renderer-v8/src/runtime/markdown_dump/visibility.rs @@ -238,20 +238,8 @@ impl<'a, D: MarkdownSource> MarkdownDom<'a, D> { Dom::node_kind(dom, node), NodeKind::Element("tr" | "thead" | "tbody" | "tfoot") ); - // The UA sheet hides , but its media element still uses it. - let media_source = matches!(Dom::node_kind(dom, node), NodeKind::Element("source")) - && dom.parent_node(node).is_some_and(|parent| { - matches!( - Dom::node_kind(dom, parent), - NodeKind::Element("video" | "audio") - ) - }); if collapsed_table_part - || (values.display == "none" - && !in_source - && !media_source - && !disclosure_root - && !disclosure_path) + || (values.display == "none" && !in_source && !disclosure_root && !disclosure_path) || (parent_is_disclosure_path && !disclosure_root && !disclosure_path) || dom.parent_node(node).is_some_and(|parent| { suppressed.contains(&parent) || hidden_contents.contains(&parent) diff --git a/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs b/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs index db914107a43..ef4b311b7c3 100644 --- a/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs +++ b/moli-renderer-v8/src/runtime/page_vm/tests/markdown_dump.rs @@ -583,6 +583,7 @@ async fn markdown_live_structure_and_visibility_have_exact_outputs() { (" ", "Volume"), (" ", "50 #000000"), (" ", "Volume 100 #ff0000"), + ("

Body text

Pic", "Body text\n\n![Pic](https://example.test/p.png)"), ("", "[Video](https://example.test/a.webm) [Video](https://example.test/a.mp4)\n\n[Audio](https://example.test/b.ogg)"), ("
AB
", "A\n\nB"), ("

AB

", "A\n\nB"), diff --git a/moli-renderer-v8/src/style_engine/ua/html.css b/moli-renderer-v8/src/style_engine/ua/html.css index a6e04c42da9..42b33e2e145 100644 --- a/moli-renderer-v8/src/style_engine/ua/html.css +++ b/moli-renderer-v8/src/style_engine/ua/html.css @@ -253,7 +253,7 @@ h6 { } base, basefont, datalist, head, link, meta, noembed, noframes, param, rp, -script, style, template, title, source { +script, style, template, title { display: none; }