8000 [AssetMapper] Link needs as="style" · symfony/symfony@6c55206 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c55206

Browse files
committed
[AssetMapper] Link needs as="style"
1 parent c6930e3 commit 6c55206

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