Преглед изворни кода

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, `<head>`) 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.
Sam Atkins пре 3 година
родитељ
комит
10429e1043
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      Userland/Services/WebContent/ConnectionFromClient.cpp

+ 1 - 1
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 {
         auto serialize_node_box_sizing_json = [](Web::Layout::Node const* layout_node) -> String {
             if (!layout_node || !layout_node->is_box()) {
             if (!layout_node || !layout_node->is_box()) {
-                return "";
+                return "{}";
             }
             }
             auto* box = static_cast<Web::Layout::Box const*>(layout_node);
             auto* box = static_cast<Web::Layout::Box const*>(layout_node);
             auto box_model = box->box_model();
             auto box_model = box->box_model();