startup: Add support for module-requirement to RLQ
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Aug 2018 17:28:44 +0000 (18:28 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Aug 2018 18:34:21 +0000 (19:34 +0100)
commit73e24f255c932136b45efcb9e13ab41f2987b55d
tree9e9279019832301386b36367c6f72d66025267e0
parent677c154af3a7f41d26b92034c579109574ca1376
startup: Add support for module-requirement to RLQ

* Add more inline documentation.

* Use [0] instead of needless 'length'. (Optimisation)

* Don't lazy-create NORLQ as empty array only to dereference
  it two statements later. (Optimisation)

* Add support for a secondary signature to RLQ.push.

  The existing signature is a plain callback function that is
  execute immediately after startup.

  The new signature is an array of `[ string|Array, Function ]`
  where the first value is required module(s), and
  the second value is the callback function.

  startup.js will leave the second form in the array, processing
  them instead in 'mediawiki.base'.

This change is needed before I17cd13dffebd6a (T192623), which
will remove the undocumented behaviour of RLQ callbacks firing
only after base modules arrive, which means we need to provide
authors of inline scripts an alternate means of scheduling
callbacks for after 'jquery' and/or 'mediawiki.base' arrive.

Bug: T192623
Change-Id: Ica7bb9c3bdb77d96ca2e01530a76f7ca448acdb8
resources/src/startup/startup.js
tests/qunit/suites/resources/mediawiki/mediawiki.base.test.js