From 1102a3186623385adb0b7823c42a692c3667fced Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 25 Apr 2025 09:35:30 +0200 Subject: [PATCH] LibWeb: Improve DOM dump formatting for HTML template elements Let's dump both the template contents, and any DOM nodes inside the template element itself, since both are valid states produced by the HTML parser. --- Libraries/LibWeb/Dump.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index a8fe444eb28..e7d140a119b 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -125,16 +125,19 @@ void dump_tree(StringBuilder& builder, DOM::Node const& node) } } } + if (is(node)) { + auto& template_element = as(node); + for (int i = 0; i < indent; ++i) + builder.append(" "sv); + builder.append("(template content)\n"sv); + dump_tree(builder, template_element.content()); + builder.append("(template normal subtree)\n"sv); + } if (is(node)) { - if (!is(node)) { - static_cast(node).for_each_child([&](auto& child) { - dump_tree(builder, child); - return IterationDecision::Continue; - }); - } else { - auto& template_element = as(node); - dump_tree(builder, template_element.content()); - } + static_cast(node).for_each_child([&](auto& child) { + dump_tree(builder, child); + return IterationDecision::Continue; + }); } --indent; }