Web Inspector: DOM Tree broken if an element has a "debounce" attribute
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Mar 2017 05:18:35 +0000 (05:18 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Mar 2017 05:18:35 +0000 (05:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169336
<rdar://problem/30899430>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-03-07
Reviewed by Brian Burg.

* UserInterface/Models/DOMNode.js:
(WebInspector.DOMNode):
(WebInspector.DOMNode.prototype.getAttribute):
(WebInspector.DOMNode.prototype.removeAttribute.mycallback):
(WebInspector.DOMNode.prototype.removeAttribute):
Convert the attributes map to an actual Map to avoid name collisions
with Object.prototype properties.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@213565 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Models/DOMNode.js

index 6c3374c..5294893 100644 (file)
@@ -1,3 +1,19 @@
+2017-03-07  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: DOM Tree broken if an element has a "debounce" attribute
+        https://bugs.webkit.org/show_bug.cgi?id=169336
+        <rdar://problem/30899430>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Models/DOMNode.js:
+        (WebInspector.DOMNode):
+        (WebInspector.DOMNode.prototype.getAttribute):
+        (WebInspector.DOMNode.prototype.removeAttribute.mycallback):
+        (WebInspector.DOMNode.prototype.removeAttribute):
+        Convert the attributes map to an actual Map to avoid name collisions
+        with Object.prototype properties.
+
 2017-03-07  Chris Dumez  <cdumez@apple.com>
 
         Drop non-standard MessageEvent.webkitInitMessageEvent()
index 636a758..0fbedc0 100644 (file)
@@ -57,7 +57,7 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
             this.ownerDocument = doc;
 
         this._attributes = [];
-        this._attributesMap = {};
+        this._attributesMap = new Map;
         if (payload.attributes)
             this._setAttributesPayload(payload.attributes);
 
@@ -387,7 +387,7 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
 
     getAttribute(name)
     {
-        var attr = this._attributesMap[name];
+        let attr = this._attributesMap.get(name);
         return attr ? attr.value : undefined;
     }
 
@@ -411,7 +411,7 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
         function mycallback(error, success)
         {
             if (!error) {
-                delete this._attributesMap[name];
+                this._attributesMap.delete(name);
                 for (var i = 0; i < this._attributes.length; ++i) {
                     if (this._attributes[i].name === name) {
                         this._attributes.splice(i, 1);
@@ -669,7 +669,7 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
     _setAttributesPayload(attrs)
     {
         this._attributes = [];
-        this._attributesMap = {};
+        this._attributesMap = new Map;
         for (var i = 0; i < attrs.length; i += 2)
             this._addAttribute(attrs[i], attrs[i + 1]);
     }
@@ -735,14 +735,14 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
 
     _addAttribute(name, value)
     {
-        var attr = {name, value, _node: this};
-        this._attributesMap[name] = attr;
+        let attr = {name, value, _node: this};
+        this._attributesMap.set(name, attr);
         this._attributes.push(attr);
     }
 
     _setAttribute(name, value)
     {
-        var attr = this._attributesMap[name];
+        let attr = this._attributesMap.get(name);
         if (attr)
             attr.value = value;
         else
@@ -751,10 +751,10 @@ WebInspector.DOMNode = class DOMNode extends WebInspector.Object
 
     _removeAttribute(name)
     {
-        var attr = this._attributesMap[name];
+        let attr = this._attributesMap.get(name);
         if (attr) {
             this._attributes.remove(attr);
-            delete this._attributesMap[name];
+            this._attributesMap.delete(name);
         }
     }