resourceloader: Simplify addEmbeddedCSS by using object refs
authorTimo Tijhof <krinklemail@gmail.com>
Sun, 26 Aug 2018 03:09:02 +0000 (04:09 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 28 Aug 2018 04:30:52 +0000 (05:30 +0100)
commit19f4db30385518772f00ddf14bd948f467624b24
treeb3efcd5a26c2618075d8df00cf14f02b7eb9eadd
parentde1fc2b127d8d9c6f607ecc8de26d17d5f9efe67
resourceloader: Simplify addEmbeddedCSS by using object refs

* Previously, the same function was used both for adding to the buffer,
  and flushing the buffer (via self-calling alternate signatures).
  The flushing logic was split off to a flushCssBuffer function.

* Previously, when encountering an '@import' statement, it performed a
  synchronous flush, instead of the usual asynchronous ones. There was
  no reason for this, other than my laziness. I suspect because I was
  using strings, which can't be passed by reference, and I didn't
  think of another way.

  I'm now storing the string in an object, which can be passed by
  reference to the flush function. This means, as before, we can
  keep appending to its string after the flush is scheduled. But,
  unlike before, it also means we can reset our local reference and
  start a new buffer at any time and schedule that one, too.

Bug: T202703
Change-Id: Ifc6dd59e9e8885d65ba425bc579ecbfb09f2ac64
resources/src/startup/mediawiki.js