mediawiki.util: Optimise logic in addPortletLink
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 1 Aug 2013 23:38:16 +0000 (01:38 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Fri, 2 Aug 2013 03:32:09 +0000 (05:32 +0200)
commit5f3b75dd360c5b5e260b47eadce45a613b6de390
tree53a95c3e99d65e8d60796bfed1c85370fc1bcc86
parent8d629551524d4bfaab633f309197361b9a793aee
mediawiki.util: Optimise logic in addPortletLink

Optimised to no longer:
* boolean cast "nextnode" twice.
* assert nextnode.jquery when we know it is a jQuery object.
  > !!$( Node ).jquery
* assert nextnode.length when we know it has only 1 element.
  > $( Node ).length === 1
* execute $ul.find( selector ) twice for the CSS selector case.
* check for .length in some places and do an ignorant eq(0) in
  other cases (thus ignoring the case if there are multiple
  elements).

Tests still pass :-)

Change-Id: Ibc86c2dc33a8a3ba378138525c2523ba69bca8f1
resources/mediawiki/mediawiki.util.js