Skip to content
Snippets Groups Projects
Verified Commit 4dd78b90 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3437839 by catch, thejimbirch, Luke.Leber: Only send libraries with...

Issue #3437839 by catch, thejimbirch, Luke.Leber: Only send libraries with aggregate URLs that have the aggregate type included
parent f91aed85
Branches
Tags
23 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!10602Issue #3438769 by vinmayiswamy, antonnavi, michelle, amateescu: Sub workspace does not clear,!10301Issue #3469309 by mstrelan, smustgrave, moshe weitzman: Use one-time login...,!10187Issue #3487488 by dakwamine: ExtensionMimeTypeGuesser::guessMimeType must support file names with "0" (zero) like foo.0.zip,!9944Issue #3483353: Consider making the createCopy config action optionally fail...,!9929Issue #3445469 by pooja_sharma, smustgrave: Add additional test coverage for...,!9787Resolve issue 3479427 - bootstrap barrio issue under Windows,!9742Issue #3463908 by catch, quietone: Split OptionsFieldUiTest into two,!9526Issue #3458177 by mondrake, catch, quietone, godotislate, longwave, larowlan,...,!8738Issue #3424162 by camilledavis, dineshkumarbollu, smustgrave: Claro...,!8704Make greek characters available in ckeditor5,!8597Draft: Issue #3442259 by catch, quietone, dww: Reduce time of Migrate Upgrade tests...,!8533Issue #3446962 by kim.pepper: Remove incorrectly added...,!8517Issue #3443748 by NexusNovaz, smustgrave: Testcase creates false positive,!8325Update file Sort.php,!8095Expose document root on install,!7930Resolve #3427374 "Taxonomytid viewsargumentdefault plugin",!7445Issue #3440169: When using drupalGet(), provide an associative array for $headers,!6502Draft: Resolve #2938524 "Plach testing issue",!38582585169-10.1.x,!3226Issue #2987537: Custom menu link entity type should not declare "bundle" entity key
Pipeline #156287 passed
Pipeline: drupal

#156311

    Pipeline: drupal

    #156309

      Pipeline: drupal

      #156297

        +1
        ......@@ -146,27 +146,30 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, Languag
        'preprocess' => TRUE,
        ];
        foreach ($libraries_to_load as $library) {
        foreach ($libraries_to_load as $key => $library) {
        [$extension, $name] = explode('/', $library, 2);
        $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
        if (isset($definition['css'])) {
        foreach ($definition['css'] as $options) {
        $options += $default_options;
        // Copy the asset library license information to each file.
        $options['license'] = $definition['license'];
        // Files with a query string cannot be preprocessed.
        if ($options['type'] === 'file' && $options['preprocess'] && str_contains($options['data'], '?')) {
        $options['preprocess'] = FALSE;
        }
        if (empty($definition['css'])) {
        unset($libraries_to_load[$key]);
        continue;
        }
        // Always add a tiny value to the weight, to conserve the insertion
        // order.
        $options['weight'] += count($css) / 30000;
        foreach ($definition['css'] as $options) {
        $options += $default_options;
        // Copy the asset library license information to each file.
        $options['license'] = $definition['license'];
        // CSS files are being keyed by the full path.
        $css[$options['data']] = $options;
        // Files with a query string cannot be preprocessed.
        if ($options['type'] === 'file' && $options['preprocess'] && str_contains($options['data'], '?')) {
        $options['preprocess'] = FALSE;
        }
        // Always add a tiny value to the weight, to conserve the insertion
        // order.
        $options['weight'] += count($css) / 30000;
        // CSS files are being keyed by the full path.
        $css[$options['data']] = $options;
        }
        }
        ......@@ -179,7 +182,7 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize, Languag
        uasort($css, [static::class, 'sort']);
        if ($optimize) {
        $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css, $libraries_to_load, $language);
        $css = \Drupal::service('asset.css.collection_optimizer')->optimize($css, array_values($libraries_to_load), $language);
        }
        }
        $this->cache->set($cid, $css, CacheBackendInterface::CACHE_PERMANENT, ['library_info']);
        ......@@ -246,14 +249,21 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize, Language
        ];
        // Collect all libraries that contain JS assets and are in the header.
        // Also remove any libraries with no JavaScript from the libraries to
        // load.
        $header_js_libraries = [];
        foreach ($libraries_to_load as $library) {
        foreach ($libraries_to_load as $key => $library) {
        [$extension, $name] = explode('/', $library, 2);
        $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
        if (isset($definition['js']) && !empty($definition['header'])) {
        if (empty($definition['js'])) {
        unset($libraries_to_load[$key]);
        continue;
        }
        if (!empty($definition['header'])) {
        $header_js_libraries[] = $library;
        }
        }
        $libraries_to_load = array_values($libraries_to_load);
        // The current list of header JS libraries are only those libraries that
        // are in the header, but their dependencies must also be loaded for them
        // to function correctly, so update the list with those.
        ......@@ -262,28 +272,26 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize, Language
        foreach ($libraries_to_load as $library) {
        [$extension, $name] = explode('/', $library, 2);
        $definition = $this->libraryDiscovery->getLibraryByName($extension, $name);
        if (isset($definition['js'])) {
        foreach ($definition['js'] as $options) {
        $options += $default_options;
        // Copy the asset library license information to each file.
        $options['license'] = $definition['license'];
        // 'scope' is a calculated option, based on which libraries are
        // marked to be loaded from the header (see above).
        $options['scope'] = in_array($library, $header_js_libraries) ? 'header' : 'footer';
        // Preprocess can only be set if caching is enabled and no
        // attributes are set.
        $options['preprocess'] = $options['cache'] && empty($options['attributes']) ? $options['preprocess'] : FALSE;
        // Always add a tiny value to the weight, to conserve the insertion
        // order.
        $options['weight'] += count($javascript) / 30000;
        // Local and external files must keep their name as the associative
        // key so the same JavaScript file is not added twice.
        $javascript[$options['data']] = $options;
        }
        foreach ($definition['js'] as $options) {
        $options += $default_options;
        // Copy the asset library license information to each file.
        $options['license'] = $definition['license'];
        // 'scope' is a calculated option, based on which libraries are
        // marked to be loaded from the header (see above).
        $options['scope'] = in_array($library, $header_js_libraries) ? 'header' : 'footer';
        // Preprocess can only be set if caching is enabled and no
        // attributes are set.
        $options['preprocess'] = $options['cache'] && empty($options['attributes']) ? $options['preprocess'] : FALSE;
        // Always add a tiny value to the weight, to conserve the insertion
        // order.
        $options['weight'] += count($javascript) / 30000;
        // Local and external files must keep their name as the associative
        // key so the same JavaScript file is not added twice.
        $javascript[$options['data']] = $options;
        }
        }
        ......
        ......@@ -26,8 +26,8 @@ public function testFrontAndRecipesPages() {
        $performance_data = $this->doRequests();
        $this->assertSame(4, $performance_data->getStylesheetCount());
        $this->assertLessThan(82500, $performance_data->getStylesheetBytes());
        $this->assertSame(2, $performance_data->getScriptCount());
        $this->assertLessThan(14500, $performance_data->getScriptBytes());
        $this->assertSame(1, $performance_data->getScriptCount());
        $this->assertLessThan(7500, $performance_data->getScriptBytes());
        }
        /**
        ......@@ -40,8 +40,8 @@ public function testFrontAndRecipesPagesAuthenticated() {
        $performance_data = $this->doRequests();
        $this->assertSame(4, $performance_data->getStylesheetCount());
        $this->assertLessThan(89500, $performance_data->getStylesheetBytes());
        $this->assertSame(2, $performance_data->getScriptCount());
        $this->assertLessThan(265000, $performance_data->getScriptBytes());
        $this->assertSame(1, $performance_data->getScriptCount());
        $this->assertLessThan(132500, $performance_data->getScriptBytes());
        }
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment