-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from UN-OCHA/develop
Deploy 28-08-2024
- Loading branch information
Showing
11 changed files
with
216 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionOptimizerLazy.php b/core/lib/Drupal/Core/Asset/JsCollectionOptimizerLazy.php | ||
index 647a2c36a017f890c0e43bbdb350084989b1a7f1..3912afe5a9feeaae235c640cd89816091c7e97be 100644 | ||
--- a/core/lib/Drupal/Core/Asset/JsCollectionOptimizerLazy.php | ||
+++ b/core/lib/Drupal/Core/Asset/JsCollectionOptimizerLazy.php | ||
@@ -155,24 +155,32 @@ public function deleteAll() { | ||
public function optimizeGroup(array $group): string { | ||
$data = ''; | ||
$current_license = FALSE; | ||
- foreach ($group['items'] as $js_asset) { | ||
- // Ensure license information is available as a comment after | ||
- // optimization. | ||
- if ($js_asset['license'] !== $current_license) { | ||
- $data .= "/* @license " . $js_asset['license']['name'] . " " . $js_asset['license']['url'] . " */\n"; | ||
- } | ||
- $current_license = $js_asset['license']; | ||
- // Optimize this JS file, but only if it's not yet minified. | ||
- if (isset($js_asset['minified']) && $js_asset['minified']) { | ||
- $data .= file_get_contents($js_asset['data']); | ||
- } | ||
- else { | ||
- $data .= $this->optimizer->optimize($js_asset); | ||
+ | ||
+ // No preprocessing, single JS asset: just use the existing URI. | ||
+ if ($group['type'] === 'file' && !$group['preprocess']) { | ||
+ $data = file_get_contents($group['items'][0]['data']); | ||
+ } | ||
+ else { | ||
+ foreach ($group['items'] as $js_asset) { | ||
+ // Ensure license information is available as a comment after | ||
+ // optimization. | ||
+ if ($js_asset['license'] !== $current_license) { | ||
+ $data .= "/* @license " . $js_asset['license']['name'] . " " . $js_asset['license']['url'] . " */\n"; | ||
+ } | ||
+ $current_license = $js_asset['license']; | ||
+ // Optimize this JS file, but only if it's not yet minified. | ||
+ if (isset($js_asset['minified']) && $js_asset['minified']) { | ||
+ $data .= file_get_contents($js_asset['data']); | ||
+ } | ||
+ else { | ||
+ $data .= $this->optimizer->optimize($js_asset); | ||
+ } | ||
+ // Append a ';' and a newline after each JS file to prevent them from | ||
+ // running together. | ||
+ $data .= ";\n"; | ||
} | ||
- // Append a ';' and a newline after each JS file to prevent them from | ||
- // running together. | ||
- $data .= ";\n"; | ||
} | ||
+ | ||
// Remove unwanted JS code that causes issues. | ||
return $this->optimizer->clean($data); | ||
} |
Oops, something went wrong.