RESOLVED FIXED 180890
Web Inspector: Can't add a new class by editing class attribute in DOM outline
https://bugs.webkit.org/show_bug.cgi?id=180890
Summary Web Inspector: Can't add a new class by editing class attribute in DOM outline
Nikita Vasilyev
Reported 2017-12-15 16:05:04 PST
Web Inspector automatically adds a non-breaking space when adding a CSS class (via double-click or enter). Because this chains the class name, it removes any styles. Also, the `&nbsp;` isn't visible unless you're editing via "Edit as HTML." Steps to Reproduce: 1. Open Web Inspector 2. Find an HTML element that has a value in the class attribute 3. Double-click the class attribute (or press Enter) 4. Add "hello" to the beginning of the attribute value 5. Right click and select "Edit as HTML" 6. Notice the `&nbsp;` Expected Results: I could double-click / enter to quickly add a class and it wouldn't automatically add a non-breaking space. Observed Results: It adds a non-breaking space, making the quick edit functionality useless. <rdar://problem/34144628>
Attachments
[Image] Bug (37.88 KB, image/png)
2017-12-15 16:06 PST, Nikita Vasilyev
no flags
Patch (1.53 KB, patch)
2018-03-16 16:34 PDT, Nikita Vasilyev
no flags
Patch (1.64 KB, patch)
2018-03-19 15:24 PDT, Nikita Vasilyev
rniwa: review+
Patch (1.63 KB, patch)
2018-03-20 00:19 PDT, Nikita Vasilyev
no flags
Nikita Vasilyev
Comment 1 2017-12-15 16:06:23 PST
Created attachment 329534 [details] [Image] Bug
Nikita Vasilyev
Comment 2 2017-12-15 16:25:33 PST
Devin, if you're looking for more bugs to fix, this's a good one! If not, feel free to set it back to unassigned.
Nikita Vasilyev
Comment 3 2018-03-16 15:34:50 PDT
This happens only on certain class names. Steps: 1. Open http://nv.github.io/webkit-inspector-bugs/styles-redesign/tests/color.html 2. Double-click on `class="item-1"` 3. Type "my-class " before the existing class name, so it looks like `class="my-class item-1"` 4. Press Enter It looks like DOMAgent.setAttributesAsText *sometimes* converts spaces to &nbsp;.
Nikita Vasilyev
Comment 4 2018-03-16 16:33:37 PDT
(In reply to Nikita Vasilyev from comment #3) > It looks like DOMAgent.setAttributesAsText *sometimes* converts spaces to > &nbsp;. No, nbsp's are coming from contentEditable.
Nikita Vasilyev
Comment 5 2018-03-16 16:34:00 PDT
Nikita Vasilyev
Comment 6 2018-03-16 16:44:17 PDT
"ContentEditable: &nbsp; is forced on SPACE between text nodes" https://bugs.chromium.org/p/chromium/issues/detail?id=310149 Fixed in Chromium on July 27, 2016 but appears to be unresolved in WebKit. This makes we concerned about other places where we use contentEditable, such as the styles editor.
Nikita Vasilyev
Comment 7 2018-03-16 17:01:34 PDT
(In reply to Nikita Vasilyev from comment #5) > Created attachment 335982 [details] > Patch To clarify, this patch makes it impossible to commit non-breaking spaces in HTML attributes and I'm fine with that. When would you want to add a non-breaking space in Web Inspector? I can't think of any common cases.
Nikita Vasilyev
Comment 8 2018-03-19 15:24:29 PDT
Ryosuke Niwa
Comment 9 2018-03-19 21:19:33 PDT
Comment on attachment 336078 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=336078&action=review > Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:1069 > + let nbspRegex = /\xA0/g; Why not const?
Matt Baker
Comment 10 2018-03-19 23:36:28 PDT
Comment on attachment 336078 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=336078&action=review >> Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js:1069 >> + let nbspRegex = /\xA0/g; > > Why not const? This should be const. We haven't settled on a convention for applying const in the WebInspector frontend. I think more widespread usage would be a benefit, but my thoughts on const-correctness come from C++, and I don't know how much of that applies to JS.
Nikita Vasilyev
Comment 11 2018-03-20 00:19:34 PDT
WebKit Commit Bot
Comment 12 2018-03-20 01:22:08 PDT
Comment on attachment 336107 [details] Patch Clearing flags on attachment: 336107 Committed r229744: <https://trac.webkit.org/changeset/229744>
WebKit Commit Bot
Comment 13 2018-03-20 01:22:09 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.