From 10429e1043a022339de8b84743caadf2da537a37 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 10 Mar 2022 11:29:09 +0000 Subject: WebContent: Return empty JSON object if element has no box model The blank string "" does not parse as JSON, and so the InspectorWidget would fail to update the box-model information when inspecting elements with no box, (for example, ``) showing stale values instead. Now, they show all 0s. You could argue that InspectorWidget should be more resilient when given invalid JSON strings, but making sure we only pass valid ones works too. --- Userland/Services/WebContent/ConnectionFromClient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Services/WebContent/ConnectionFromClient.cpp b/Userland/Services/WebContent/ConnectionFromClient.cpp index 001ffdd3f8..7b9c9cb96f 100644 --- a/Userland/Services/WebContent/ConnectionFromClient.cpp +++ b/Userland/Services/WebContent/ConnectionFromClient.cpp @@ -304,7 +304,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect }; auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> String { if (!layout_node || !layout_node->is_box()) { - return ""; + return "{}"; } auto* box = static_cast(layout_node); auto box_model = box->box_model(); -- cgit v1.2.3