Web Inspector: support undo/redo of insertAdjacentHTML
[WebKit-https.git] / Source / WebInspectorUI / UserInterface / Models / DOMNode.js
index 94dd208..1de69f1 100644 (file)
@@ -505,16 +505,20 @@ WI.DOMNode = class DOMNode extends WI.Object
         if (this.nodeType() !== Node.ELEMENT_NODE)
             return;
 
-        // FIXME: <https://webkit.org/b/179283> Web Inspector: support undo/redo of insertAdjacentHTML
+        // COMPATIBILITY (iOS 11.0): DOM.insertAdjacentHTML did not exist.
+        if (!DOMAgent.insertAdjacentHTML) {
+            WI.RemoteObject.resolveNode(this).then((object) => {
+                function inspectedPage_node_insertAdjacentHTML(position, html) {
+                    this.insertAdjacentHTML(position, html);
+                }
 
-        WI.RemoteObject.resolveNode(this).then((object) => {
-            function inspectedPage_node_insertAdjacentHTML(position, html) {
-                this.insertAdjacentHTML(position, html);
-            }
+                object.callFunction(inspectedPage_node_insertAdjacentHTML, [position, html]);
+                object.release();
+            });
+            return;
+        }
 
-            object.callFunction(inspectedPage_node_insertAdjacentHTML, [position, html]);
-            object.release();
-        });
+        DOMAgent.insertAdjacentHTML(this.id, position, html, this._makeUndoableCallback());
     }
 
     removeNode(callback)