Kaynağa Gözat

LibWeb: Invalidate the layout tree on DOM node insertion

Andreas Kling 2 yıl önce
ebeveyn
işleme
3cea86632d

+ 2 - 0
Tests/LibWeb/Text/expected/append-child-must-update-layout-tree.txt

@@ -0,0 +1,2 @@
+Hello
+friends

+ 8 - 0
Tests/LibWeb/Text/input/append-child-must-update-layout-tree.html

@@ -0,0 +1,8 @@
+<script src="include.js"></script>
+<script>
+    test(() => {
+        println("Hello");
+        document.body.offsetWidth // Force a layout
+        println("friends"); // This will append a text child to the output element, and should update the layout tree.
+    });
+</script>

+ 2 - 0
Userland/Libraries/LibWeb/DOM/Node.cpp

@@ -487,6 +487,8 @@ void Node::insert_before(JS::NonnullGCPtr<Node> node, JS::GCPtr<Node> child, boo
 
     // FIXME: This will need to become smarter when we implement the :has() selector.
     invalidate_style();
+
+    document().invalidate_layout();
 }
 
 // https://dom.spec.whatwg.org/#concept-node-pre-insert