Web Inspector: Styles Redesign: can't add new property after property without trailin...
authornvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 23:16:20 +0000 (23:16 +0000)
committernvasilyev@apple.com <nvasilyev@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Nov 2017 23:16:20 +0000 (23:16 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179587
<rdar://problem/35490858>

Reviewed by Timothy Hatcher.

* UserInterface/Models/CSSProperty.js:
(WI.CSSProperty.prototype._updateOwnerStyleText):
(WI.CSSProperty.prototype._appendSemicolonIfNeeded):
Add a semicolon before the new property if the last property doesn't have it already.

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

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

index 04c61b7..7c1fd8e 100644 (file)
@@ -1,3 +1,16 @@
+2017-11-29  Nikita Vasilyev  <nvasilyev@apple.com>
+
+        Web Inspector: Styles Redesign: can't add new property after property without trailing semicolon
+        https://bugs.webkit.org/show_bug.cgi?id=179587
+        <rdar://problem/35490858>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/CSSProperty.js:
+        (WI.CSSProperty.prototype._updateOwnerStyleText):
+        (WI.CSSProperty.prototype._appendSemicolonIfNeeded):
+        Add a semicolon before the new property if the last property doesn't have it already.
+
 2017-11-29  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Console Tab navigation bar sometimes does not include filter bar, clear console sometimes does not work
index 8706494..c048a1d 100644 (file)
@@ -361,7 +361,7 @@ WI.CSSProperty = class CSSProperty extends WI.Object
 
         console.assert(oldText === styleText.slice(range.startOffset, range.endOffset), "_styleSheetTextRange data is invalid.");
 
-        let newStyleText = styleText.slice(0, range.startOffset) + newText + styleText.slice(range.endOffset);
+        let newStyleText = this._appendSemicolonIfNeeded(styleText.slice(0, range.startOffset)) + newText + styleText.slice(range.endOffset);
 
         let lineDelta = newText.lineCount - oldText.lineCount;
         let columnDelta = newText.lastLine.length - oldText.lastLine.length;
@@ -372,6 +372,14 @@ WI.CSSProperty = class CSSProperty extends WI.Object
         let propertyWasRemoved = !newText;
         this._ownerStyle.shiftPropertiesAfter(this, lineDelta, columnDelta, propertyWasRemoved);
     }
+
+    _appendSemicolonIfNeeded(styleText)
+    {
+        if (/[^;\s]\s*$/.test(styleText))
+            return styleText.trimRight() + "; ";
+
+        return styleText;
+    }
 };
 
 WI.CSSProperty.Event = {