<table><tr><td style="">broulik added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D28666">View Revision</a></tr></table><br /><div><div><p>+1 for the <tt style="background: #ebebeb; font-size: 13px;">.some()</tt> use<br />
-1 on the convoluted <tt style="background: #ebebeb; font-size: 13px;">Array.prototype</tt> things, especially when chained.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D28666#inline-163302">View Inline</a><span style="color: #4b4d51; font-weight: bold;">Action.qml:156</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #004012">readonly</span> <span style="color: #004012">property</span> <span style="color: #aa4000">var</span> <span style="color: #aa4000">visibleChildren:</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">var</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">visible</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="p"><span class="bright">[];</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">var</span> <span style="color: #004012">child</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">for</span> <span class="p">(</span><span style="color: #aa4000">var</span> <span style="color: #004012">i</span> <span style="color: #aa4000">in</span> <span style="color: #004012">children</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #004012">child</span> <span style="color: #aa2211">=</span> <span style="color: #004012">children</span><span class="p">[</span><span style="color: #004012">i</span><span class="p">];</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">if</span> <span class="p">(</span><span style="color: #aa2211">!</span><span style="color: #004012">child</span><span class="p">.</span><span style="color: #004012">hasOwnProperty</span><span class="p">(</span><span style="color: #766510">"visible"</span><span class="p">)</span> <span style="color: #aa2211">||</span> <span style="color: #004012">child</span><span class="p">.</span><span style="color: #004012">visible</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #004012">visible</span><span class="p">.</span><span style="color: #004012">push</span><span class="p">(</span><span style="color: #004012">child</span><span class="p">)</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #aa4000">return</span> <span style="color: #004012">visible</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">return</span></span><span class="bright"> </span><span style="color: #304a96"><span class="bright">Array</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">prototype</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">filter</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">call</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">children</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">child</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=></span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">!</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">child</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">hasOwnProperty</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"visible"</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">||</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">child</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">visible</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Why are you going through the prototype? Or is <tt style="background: #ebebeb; font-size: 13px;">children</tt> not a "proper" Array?<br />
Also, can we use spread operator <tt style="background: #ebebeb; font-size: 13px;">...</tt> here?<br />
And yes, please make those a bit more readable by using useful line breaks and using parentheses and braces.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D28666#inline-163303">View Inline</a><span style="color: #4b4d51; font-weight: bold;">FormLayout.qml:85</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">var</span> <span style="color: #004012">hint</span> <span style="color: #aa2211">=</span> <span style="color: #601200">0</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">var</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">i</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">in</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">knownItems</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #004012">hint</span> <span style="color: #aa2211">=</span> <span style="color: #304a96">Math</span><span class="p">.</span><span style="color: #004012">max</span><span class="p">(</span><span style="color: #004012">hint</span><span class="p">,</span> <span style="color: #004012">knownItems</span><span class="p">[</span><span style="color: #004012">i</span><span class="p">].</span><span style="color: #004012">Layout</span><span class="p">.</span><span style="color: #004012">preferredWidth</span> <span style="color: #aa2211">></span> <span style="color: #601200">0</span> <span style="color: #aa2211">?</span> <span style="color: #004012">knownItems</span><span class="p">[</span><span style="color: #004012">i</span><span class="p">].</span><span style="color: #aa4000">Layout.preferredWidth :</span> <span style="color: #004012">knownItems</span><span class="p">[</span><span style="color: #004012">i</span><span class="p">].</span><span style="color: #004012">implicitWidth</span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"></span><span style="color: #004012"><span class="bright">knownItems</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">forEach</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">item</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=></span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">hint</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span style="color: #304a96"><span class="bright">Math</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">max</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">hint</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">item</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">Layout</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">preferredWidth</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">></span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">0</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">?</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">item.Layout.preferredWidth :</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">item</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">implicitWidth</span></span><span class="bright"></span><span class="p"><span class="bright">));</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #aa4000">return</span> <span style="color: #004012">hint</span><span class="p">;</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Looks like a usecas for <tt style="background: #ebebeb; font-size: 13px;">Array.reduce</tt>?</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D28666#inline-163304">View Inline</a><span style="color: #4b4d51; font-weight: bold;">PassiveNotification.qml:62</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">let</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">i</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">0</span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">i</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright"><</span></span><span class="bright"> </span><span style="color: #004012">outerLayout</span><span class="p">.</span><span style="color: #004012">children</span><span class="p">.<span class="bright"></span></span><span class="bright"></span><span style="color: #004012"><span class="bright">length</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">-</span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">3</span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">++</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">i</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span style="color: #004012">outerLayout</span><span class="p">.</span><span style="color: #004012">children</span><span class="p">[</span><span style="color: #004012">i</span><span class="p">].</span><span style="color: #004012">close</span><span class="p">();</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="p">}</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #004012">outerLayout</span><span class="p">.</span><span style="color: #004012">children</span><span class="p">.<span class="bright"></span></span><span class="bright"></span><span style="color: #004012"><span class="bright">slice</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #601200"><span class="bright">0</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">-</span></span><span class="bright"></span><span style="color: #601200"><span class="bright">3</span></span><span class="bright"></span><span class="p"><span class="bright">).</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">forEach</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">child</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=></span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">child</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">close</span></span><span class="bright"></span><span class="p"><span class="bright">());</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">I would like a comment here. Note veryone is faimilar with <tt style="background: #ebebeb; font-size: 13px;">slice</tt> in that fashion.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D28666#inline-163305">View Inline</a><span style="color: #4b4d51; font-weight: bold;">PassiveNotification.qml:72</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; "> <span style="color: #74777d">// Reorder items to have the last on top</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">let</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">children</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span style="color: #004012">outerLayout</span><span class="p">.</span><span style="color: #004012">children<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);"> <span class="bright"></span><span style="color: #aa4000"><span class="bright">for</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">let</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">i</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">in</span></span><span class="bright"> </span><span style="color: #004012">children<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span style="color: #004012">outerLayout</span><span class="p">.</span><span style="color: #004012">children<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">forEach</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa4000"><span class="bright">function</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">value</span></span><span class="bright"></span><span class="p"><span class="bright">,</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">)</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=></span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);"> <span class="bright"> </span><span style="color: #004012"><span class="bright">value</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">Layout</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">row</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span style="color: #004012"><span class="bright">outerLayout</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span style="color: #004012">children<span class="bright"></span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">length</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-</span></span><span class="bright"></span><span style="color: #601200"><span class="bright">1</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">-</span></span><span class="bright"></span><span style="color: #004012"><span class="bright">index</span></span><span class="bright"></span><span class="p"><span class="bright">;</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Why no arrow function?</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R169 Kirigami</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D28666">https://phabricator.kde.org/D28666</a></div></div><br /><div><strong>To: </strong>cblack, Kirigami<br /><strong>Cc: </strong>broulik, ngraham, plasma-devel, fbampaloukas, GB_2, domson, dkardarakos, apol, ahiemstra, davidedmundson, mart<br /></div>