8000 bug #52108 [AssetMapper] Link needs as="style" (weaverryan) · symfony/symfony@b9122bc · GitHub
[go: up one dir, main page]

Skip to content

Commit b9122bc

Browse files
bug #52108 [AssetMapper] Link needs as="style" (weaverryan)
This PR was merged into the 6.4 branch. Discussion ---------- [AssetMapper] Link needs as="style" | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Mentioned on symfony/recipes#1245 (comment) | License | MIT Hi! The `as="style"` is required. It was missing from the docs (I'll make a PR there) and so I forgot it :). Tested on a real project to verify the warning was gone. Cheers! Commits ------- 6c55206 [AssetMapper] Link needs as="style"
2 parents 43bcef0 + 6c55206 commit b9122bc

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ private function createAttributesString(array $attributes): string
163163

164164
private function addWebLinkPreloads(Request $request, array $cssLinks): void
165165
{
166-
$cssPreloadLinks = array_map(fn ($url) => new Link('preload', $url), $cssLinks);
166+
$cssPreloadLinks = array_map(fn ($url) => (new Link('preload', $url))->withAttribute('as', 'style'), $cssLinks);
167167

168168
if (null === $linkProvider = $request->attributes->get('_links')) {
169169
$request->attributes->set('_links', new GenericLinkProvider($cssPreloadLinks));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ public function testItAddsPreloadLinks()
195195
$this->assertInstanceOf(GenericLinkProvider::class, $linkProvider);
196196
$this->assertCount(1, $linkProvider->getLinks());
197197
$this->assertSame(['preload'], $linkProvider->getLinks()[0]->getRels());
198+
$this->assertSame(['as' => 'style'], $linkProvider->getLinks()[0]->getAttributes());
198199
$this->assertSame('/assets/styles/app-preload-d1g35t.css', $linkProvider->getLinks()[0]->getHref());
199200
}
200201
}

0 commit comments

Comments
 (0)
0