Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald committed Sep 14, 2022
1 parent 1d6659a commit 2711719
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions src/Illuminate/Foundation/Vite.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ class Vite implements Htmlable
protected $preloadTagAttributesResolvers = [];

/**
* The preloaded tags.
* The preloaded assets.
*
* @var array
*/
protected $preloadedTags = [];
protected $preloadedAssets = [];

/**
* The cached manifest files.
Expand All @@ -81,13 +81,13 @@ class Vite implements Htmlable
protected static $manifests = [];

/**
* Get the preloaded tags.
* Get the preloaded assets.
*
* @var array
*/
public function preloadedTags()
public function preloadedAssets()
{
return $this->preloadedTags;
return $this->preloadedAssets;
}

/**
Expand Down Expand Up @@ -368,7 +368,7 @@ protected function makePreloadTagForChunk($src, $url, $chunk, $manifest)
{
$attributes = $this->resolvePreloadTagAttributes($src, $url, $chunk, $manifest);

$this->preloadedTags[$url] = $this->parseAttributes(
$this->preloadedAssets[$url] = $this->parseAttributes(
Collection::make($attributes)->forget('href')->all()
);

Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Http/Middleware/VitePreloading.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class VitePreloading
public function handle($request, $next)
{
return tap($next($request), function ($response) {
if (Vite::preloadedTags() !== []) {
$response->header('Link', Collection::make(Vite::preloadedTags())
if (Vite::preloadedAssets() !== []) {
$response->header('Link', Collection::make(Vite::preloadedAssets())
->map(fn ($attributes, $url) => "<{$url}>; ".implode('; ', $attributes))
->sortByDesc(fn ($link) => str_contains($link, 'rel="preload"'))
->join(', '));
Expand Down
6 changes: 3 additions & 3 deletions tests/Foundation/FoundationViteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,12 +662,12 @@ public function testItGeneratesPreloadDirectivesForJsAndCssImports()
'https://example.com/'.$buildDir.'/assets/_plugin-vue_export-helper.cdc0426e.js' => [
'rel="modulepreload"',
],
], ViteFacade::preloadedTags());
], ViteFacade::preloadedAssets());

$this->cleanViteManifest($buildDir);
}

public function testItCanSpecifyAttributesForPreloadedTags()
public function testItCanSpecifyAttributesForPreloadedAssets()
{
$buildDir = Str::random();
$this->makeViteManifest([
Expand Down Expand Up @@ -792,7 +792,7 @@ public function testItCanSpecifyAttributesForPreloadedTags()
'empty-string=""',
'zero="0"',
],
], ViteFacade::preloadedTags());
], ViteFacade::preloadedAssets());

$this->cleanViteManifest($buildDir);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Http/Middleware/VitePreloadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testItDoesNotSetLinkTagWhenNoTagsHaveBeenPreloaded()
$app = new Container();
$app->instance(Vite::class, new class extends Vite
{
protected $preloadedTags = [];
protected $preloadedAssets = [];
});
Facade::setFacadeApplication($app);

Expand All @@ -39,7 +39,7 @@ public function testItAddsPreloadLinkHeader()
$app = new Container();
$app->instance(Vite::class, new class extends Vite
{
protected $preloadedTags = [
protected $preloadedAssets = [
'https://laravel.com/app.js' => [
'rel="modulepreload"',
'foo="bar"',
Expand All @@ -63,7 +63,7 @@ public function testItPrioritizesCss()
$app = new Container();
$app->instance(Vite::class, new class extends Vite
{
protected $preloadedTags = [
protected $preloadedAssets = [
'https://laravel.com/app.js' => [
'rel="modulepreload"',
'foo="bar"',
Expand Down

0 comments on commit 2711719

Please sign in to comment.