<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: Ability to Copy entire CSS Rule from Styles Sidebar"
href="https://bugs.webkit.org/show_bug.cgi?id=138812#c7">Comment # 7</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Web Inspector: Ability to Copy entire CSS Rule from Styles Sidebar"
href="https://bugs.webkit.org/show_bug.cgi?id=138812">bug 138812</a>
from <span class="vcard"><a class="email" href="mailto:joepeck@webkit.org" title="Joseph Pecoraro <joepeck@webkit.org>"> <span class="fn">Joseph Pecoraro</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=254299&action=diff" name="attach_254299" title="Patch">attachment 254299</a> <a href="attachment.cgi?id=254299&action=edit" title="Patch">[details]</a></span>
Patch
View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=254299&action=review">https://bugs.webkit.org/attachment.cgi?id=254299&action=review</a>
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:108
> + this._headerElement.addEventListener("contextmenu", function(event) {</span >
Style: We would probably have a _handleContextMenuEvent method down below and here we would just have:
this._headerElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this));
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:110
> + if (window.getSelection().toString().length)
> + return;</span >
What is this bail for?
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:115
> + InspectorFrontendHost.copyText(this._generateCSSRuleString.call(this));</span >
Nit: this.foo.call(this) is no different than this.foo();
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:293
> + _generateCSSRuleString: function() {</span >
Style: Brace on new line.
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:301
> + function repeatText(text, numRepeats) {
> + var output = "";
> +
> + for (var i = 0; i < numRepeats; ++i)
> + output += text;
> +
> + return output;
> + }</span >
Actually, we support String.prototype.repeat. So you could just do:
"test".repeat(3)
And get:
"testtesttest"
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:312
> + for (var i = numMediaQueries - 1; i >= 0; --i)
> + styleText += repeatText(" ", numMediaQueries - i - 1) + "@media " + mediaList[i].text + " {\n";</span >
I wonder if this would be a good place to adopt template strings:
styleText += `${" ".repeat(numMediaQueries - i - 1)} @media ${mediaList[i].text} {\n`
But maybe I'm just getting too excited. Stick with just strings for now.
<span class="quote">> Source/WebInspectorUI/UserInterface/Views/CSSStyleDeclarationSection.js:325
> + if (styleText.slice(-1) !== ";")
> + styleText += ";";</span >
I think: !styleText.endsWith(";") is more expressive.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>