Verified Commit e8961de1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2032967 by catch, joelpittet, thedavidmeister, alansaviolobo:...

Issue #2032967 by catch, joelpittet, thedavidmeister, alansaviolobo: AssetResolver::getCssAssets() should not try to sort and optimise if $css is empty

(cherry picked from commit dc39dd56)
parent 325b3611
Loading
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -170,12 +170,14 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, Languag
    $this->moduleHandler->alter('css', $css, $assets, $language);
    $this->themeManager->alter('css', $css, $assets, $language);

    if (!empty($css)) {
      // Sort CSS items, so that they appear in the correct order.
      uasort($css, [static::class, 'sort']);

      if ($optimize) {
        $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css, $libraries_to_load, $language);
      }
    }
    $this->cache->set($cid, $css, CacheBackendInterface::CACHE_PERMANENT, ['library_info']);

    return $css;