Title: [189008] trunk/Source/WebInspectorUI
Revision
189008
Author
commit-qu...@webkit.org
Date
2015-08-26 18:28:06 -0700 (Wed, 26 Aug 2015)

Log Message

Web Inspector: Uncaught exception in CSS Completion - TypeError: undefined is not an object (evaluating 'this._values[middleIndex].startsWith')
https://bugs.webkit.org/show_bug.cgi?id=148508

Patch by Joseph Pecoraro <pecor...@apple.com> on 2015-08-26
Reviewed by Timothy Hatcher.

* UserInterface/Models/CSSCompletions.js:
(WebInspector.CSSCompletions):
Add a comment explaining that the constructor may be called with
a list of strings or a list of objects from the protocol. Add
a fast path for when this is constructed with a list of strings.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (189007 => 189008)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-08-27 01:10:45 UTC (rev 189007)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-08-27 01:28:06 UTC (rev 189008)
@@ -1,3 +1,16 @@
+2015-08-26  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: Uncaught exception in CSS Completion - TypeError: undefined is not an object (evaluating 'this._values[middleIndex].startsWith')
+        https://bugs.webkit.org/show_bug.cgi?id=148508
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/CSSCompletions.js:
+        (WebInspector.CSSCompletions):
+        Add a comment explaining that the constructor may be called with
+        a list of strings or a list of objects from the protocol. Add
+        a fast path for when this is constructed with a list of strings.
+
 2015-08-26  Matt Baker  <mattba...@apple.com>
 
         Web Inspector: Rendering Frames timeline pie chart should use SVG instead of 2D canvas

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js (189007 => 189008)


--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-08-27 01:10:45 UTC (rev 189007)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js	2015-08-27 01:28:06 UTC (rev 189008)
@@ -39,24 +39,33 @@
         this._longhands = {};
         this._shorthands = {};
 
-        for (var property of properties) {
-            var propertyName = property.name;
-            this._values.push(propertyName);
+        // The `properties` parameter can be either a list of objects with 'name' / 'longhand'
+        // properties when initialized from the protocol for CSSCompletions.cssNameCompletions.
+        // Or it may just a list of strings when quickly initialized for other completion purposes.
+        if (properties.length && typeof properties[0] === "string")
+            this._values = this._values.concat(properties);
+        else {
+            for (var property of properties) {
+                var propertyName = property.name;
+                console.assert(propertyName);
 
-            var longhands = property.longhands;
-            if (longhands) {
-                this._longhands[propertyName] = longhands;
+                this._values.push(propertyName);
 
-                for (var j = 0; j < longhands.length; ++j) {
-                    var longhandName = longhands[j];
+                var longhands = property.longhands;
+                if (longhands) {
+                    this._longhands[propertyName] = longhands;
 
-                    var shorthands = this._shorthands[longhandName];
-                    if (!shorthands) {
-                        shorthands = [];
-                        this._shorthands[longhandName] = shorthands;
+                    for (var j = 0; j < longhands.length; ++j) {
+                        var longhandName = longhands[j];
+
+                        var shorthands = this._shorthands[longhandName];
+                        if (!shorthands) {
+                            shorthands = [];
+                            this._shorthands[longhandName] = shorthands;
+                        }
+
+                        shorthands.push(propertyName);
                     }
-
-                    shorthands.push(propertyName);
                 }
             }
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to