1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 17:27:46 +00:00

LibWeb: Show DOM comment contents in DOM inspector

This commit is contained in:
Andreas Kling 2021-11-02 19:25:15 +01:00
parent 5db51d85a3
commit 5088846606
2 changed files with 5 additions and 0 deletions

View file

@ -714,6 +714,9 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
auto text_node = static_cast<DOM::Text const*>(this);
object.add("text", text_node->data());
} else if (is_comment()) {
object.add("type"sv, "comment"sv);
object.add("data"sv, static_cast<DOM::Comment const&>(*this).data());
}
if (has_child_nodes()) {

View file

@ -129,6 +129,8 @@ GUI::Variant DOMTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole rol
if (role == GUI::ModelRole::Display) {
if (type == "text")
return with_whitespace_collapsed(node.get("text").as_string());
if (type == "comment"sv)
return String::formatted("<!--{}-->", node.get("data"sv).as_string());
if (type != "element")
return node_name;