diff --git a/packages/astro/src/vite-plugin-head/index.ts b/packages/astro/src/vite-plugin-head/index.ts index ae49e7401..9b0a7fb55 100644 --- a/packages/astro/src/vite-plugin-head/index.ts +++ b/packages/astro/src/vite-plugin-head/index.ts @@ -58,10 +58,10 @@ export default function configHeadVitePlugin(): vite.Plugin { propagateMetadata.call(this, id, 'containsHead', true); } - if(info && getAstroMetadata(info)?.propagation === 'self') { + if (info && getAstroMetadata(info)?.propagation === 'self') { const mod = server.moduleGraph.getModuleById(id); for (const parent of mod?.importers ?? []) { - if(parent.id) { + if (parent.id) { propagateMetadata.call(this, parent.id, 'propagation', 'in-tree'); } } @@ -100,18 +100,18 @@ export function astroHeadBuildPlugin(internals: BuildInternals): AstroBuildPlugi const modinfo = this.getModuleInfo(id); // tag in the tree - if(modinfo) { + if (modinfo) { const meta = getAstroMetadata(modinfo); - if(meta?.containsHead) { + if (meta?.containsHead) { for (const [pageInfo] of getTopLevelPages(id, this)) { let metadata = getOrCreateMetadata(pageInfo.id); metadata.containsHead = true; } } - if(meta?.propagation === 'self') { + if (meta?.propagation === 'self') { for (const [info] of walkParentInfos(id, this)) { let metadata = getOrCreateMetadata(info.id); - if(metadata.propagation !== 'self') { + if (metadata.propagation !== 'self') { metadata.propagation = 'in-tree'; } } diff --git a/packages/astro/test/units/dev/head-injection.test.js b/packages/astro/test/units/dev/head-injection.test.js index 967ad8725..9b38feae6 100644 --- a/packages/astro/test/units/dev/head-injection.test.js +++ b/packages/astro/test/units/dev/head-injection.test.js @@ -179,7 +179,10 @@ describe('head injection', () => { const html = await text(); const $ = cheerio.load(html); - expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf(1, 'found inner link'); + expect($('link[rel=stylesheet][href="/some/fake/styles.css"]')).to.have.a.lengthOf( + 1, + 'found inner link' + ); expect($('#other')).to.have.a.lengthOf(1, 'Found the #other div'); } );