8000 minor #59549 [AssetMapper] Remove `async` from the polyfill loading s… · symfony/symfony@8c941de · GitHub
[go: up one dir, main page]

Skip to content

Commit 8c941de

Browse files
minor #59549 [AssetMapper] Remove async from the polyfill loading script (MatTheCat)
This PR was merged into the 7.3 branch. Discussion ---------- [AssetMapper] Remove `async` from the polyfill loading script | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix #59547 | License | MIT From https://javascript.info/script-async-defer: > the `async` attribute is ignored if the `<script>` tag has no `src`. and > Dynamic scripts behave as “async” by default. Commits ------- 164af69 [AssetMapper] Remove `async` from the polyfill loading script
2 parents a151802 + 164af69 commit 8c941de

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/Symfony/Component/AssetMapper/ImportMap/ImportMapRenderer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,10 @@ public function render(string|array $entryPoint, array $attributes = []): string
125125
}
126126

127127
$output .= <<<HTML
128-
<script async$scriptAttributes>
128+
<script$scriptAttributes>
129129
if (!HTMLScriptElement.supports || !HTMLScriptElement.supports('importmap')) (function () {
130130
const script = document.createElement('script');
131131
script.src = '{$this->escapeAttributeValue($polyfillPath, \ENT_NOQUOTES)}';
132-
script.setAttribute('async', 'async');
133132
{$this->createAttributesString($polyfillAttributes, "script.setAttribute('%s', '%s');", "\n ", \ENT_NOQUOTES)}
134133
document.head.appendChild(script);
135134
})();

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapRendererTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ public function testCustomScriptAttributes()
132132
]);
133133
$html = $renderer->render([]);
134134
$this->assertStringContainsString('<script type="importmap" something data-turbo-track="reload">', $html);
135-
$this->assertStringContainsString('<script async something data-turbo-track="reload">', $html);
135+
$this->assertStringContainsString('<script something data-turbo-track="reload">', $html);
136136
$this->assertStringContainsString(<<<EOTXT
137137
script.src = 'https://polyfillUrl.example';
138-
script.setAttribute('async', 'async');
139138
script.setAttribute('something', 'something');
140139
script.setAttribute('data-turbo-track', 'reload');
141140
EOTXT, $html);

0 commit comments

Comments
 (0)
0