resourceloader: Refactor empty value trimming for mw.loader.register
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 9 Dec 2014 00:29:19 +0000 (00:29 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 9 Dec 2014 00:47:14 +0000 (00:47 +0000)
commitc0c221bfe449bacc91d186afb1d910353c7b675a
tree7d2fdbf8c6cc29584c5f5167611a8be8b9010831
parente145b81e5d7669e1c646e002b6c031ed405a8486
resourceloader: Refactor empty value trimming for mw.loader.register

We already did this, but it was rather convoluted with lots of
if/elseif sequences checking all the possible values.

Remove this logic from ResourceLoaderStartUpModule. Simplying it
simply create the array and pass it to ResourceLoader::makeLoaderRegisterScript.

In makeLoaderRegisterScript, we apply a filter to the array(s) that
trim empty values.

While at it:
* As with other registration properties' default values (like for dependencies,
  group, and skip) also use 'null' for the default value of 'source'.
  The mediawiki.js client was already compatible with this, and the server omitted
  it if it was the last value in the list. But in all other cases it explicitly
  outputs "local". Use null instead of simplicity sake. This also gains us a
  few characters in the output, and a relatively larger win after gzip since
  there's lots more re-using of "null".
* Remove stray casting of $version to int. This only happened in case of
  registering a single module (which don't do anywhere), and is redundant.

Change-Id: I1f321e7b8bd3b5cffc550b51169957a3da9b971d
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderStartUpModule.php
tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php