astro 5.6.1 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/client.d.ts +3 -0
  2. package/components/Font.astro +32 -0
  3. package/dist/actions/plugins.js +2 -2
  4. package/dist/assets/fonts/config.d.ts +378 -0
  5. package/dist/assets/fonts/config.js +157 -0
  6. package/dist/assets/fonts/constants.d.ts +15 -0
  7. package/dist/assets/fonts/constants.js +41 -0
  8. package/dist/assets/fonts/load.d.ts +20 -0
  9. package/dist/assets/fonts/load.js +133 -0
  10. package/dist/assets/fonts/metrics.d.ts +10 -0
  11. package/dist/assets/fonts/metrics.js +84 -0
  12. package/dist/assets/fonts/providers/entrypoints/adobe.d.ts +2 -0
  13. package/dist/assets/fonts/providers/entrypoints/adobe.js +5 -0
  14. package/dist/assets/fonts/providers/entrypoints/bunny.d.ts +1 -0
  15. package/dist/assets/fonts/providers/entrypoints/bunny.js +5 -0
  16. package/dist/assets/fonts/providers/entrypoints/fontshare.d.ts +1 -0
  17. package/dist/assets/fonts/providers/entrypoints/fontshare.js +5 -0
  18. package/dist/assets/fonts/providers/entrypoints/fontsource.d.ts +1 -0
  19. package/dist/assets/fonts/providers/entrypoints/fontsource.js +5 -0
  20. package/dist/assets/fonts/providers/entrypoints/google.d.ts +2 -0
  21. package/dist/assets/fonts/providers/entrypoints/google.js +5 -0
  22. package/dist/assets/fonts/providers/index.d.ts +48 -0
  23. package/dist/assets/fonts/providers/index.js +40 -0
  24. package/dist/assets/fonts/providers/local.d.ts +10 -0
  25. package/dist/assets/fonts/providers/local.js +30 -0
  26. package/dist/assets/fonts/providers/utils.d.ts +9 -0
  27. package/dist/assets/fonts/providers/utils.js +37 -0
  28. package/dist/assets/fonts/sync.d.ts +2 -0
  29. package/dist/assets/fonts/sync.js +17 -0
  30. package/dist/assets/fonts/types.d.ts +45 -0
  31. package/dist/assets/fonts/types.js +0 -0
  32. package/dist/assets/fonts/utils.d.ts +95 -0
  33. package/dist/assets/fonts/utils.js +215 -0
  34. package/dist/assets/fonts/vite-plugin-fonts.d.ts +10 -0
  35. package/dist/assets/fonts/vite-plugin-fonts.js +217 -0
  36. package/dist/assets/utils/index.d.ts +5 -1
  37. package/dist/assets/utils/index.js +5 -1
  38. package/dist/assets/utils/node/emitAsset.d.ts +12 -2
  39. package/dist/assets/utils/node/emitAsset.js +46 -4
  40. package/dist/assets/utils/vendor/image-size/types/index.d.ts +2 -2
  41. package/dist/assets/vite-plugin-assets.d.ts +9 -2
  42. package/dist/assets/vite-plugin-assets.js +9 -6
  43. package/dist/cli/add/index.js +3 -1
  44. package/dist/cli/install-package.js +3 -0
  45. package/dist/config/entrypoint.d.ts +2 -0
  46. package/dist/config/entrypoint.js +3 -0
  47. package/dist/config/index.d.ts +2 -1
  48. package/dist/content/content-layer.js +5 -4
  49. package/dist/content/runtime-assets.js +1 -0
  50. package/dist/content/utils.d.ts +10 -10
  51. package/dist/content/vite-plugin-content-imports.js +4 -2
  52. package/dist/core/build/generate.js +2 -2
  53. package/dist/core/build/pipeline.js +2 -2
  54. package/dist/core/build/plugins/plugin-prerender.js +0 -3
  55. package/dist/core/build/static-build.js +2 -2
  56. package/dist/core/config/schemas/base.d.ts +446 -49
  57. package/dist/core/config/schemas/base.js +3 -7
  58. package/dist/core/config/schemas/refined.js +12 -0
  59. package/dist/core/config/schemas/relative.d.ts +581 -77
  60. package/dist/core/config/schemas/relative.js +1 -2
  61. package/dist/core/constants.js +1 -1
  62. package/dist/core/create-vite.js +2 -2
  63. package/dist/core/dev/dev.js +1 -1
  64. package/dist/core/errors/errors-data.d.ts +82 -26
  65. package/dist/core/errors/errors-data.js +45 -16
  66. package/dist/core/logger/core.d.ts +1 -1
  67. package/dist/core/messages.js +2 -2
  68. package/dist/core/middleware/vite-plugin.js +2 -2
  69. package/dist/core/render-context.js +39 -5
  70. package/dist/core/routing/rewrite.js +14 -5
  71. package/dist/core/session.d.ts +2 -4
  72. package/dist/core/session.js +4 -29
  73. package/dist/core/sync/index.js +2 -0
  74. package/dist/env/schema.d.ts +6 -6
  75. package/dist/integrations/hooks.js +2 -3
  76. package/dist/manifest/virtual-module.d.ts +1 -5
  77. package/dist/manifest/virtual-module.js +1 -18
  78. package/dist/prerender/utils.d.ts +5 -1
  79. package/dist/prerender/utils.js +8 -8
  80. package/dist/runtime/client/dev-toolbar/apps/audit/annotations.d.ts +6 -0
  81. package/dist/runtime/client/dev-toolbar/apps/audit/annotations.js +27 -0
  82. package/dist/runtime/client/dev-toolbar/apps/audit/index.js +10 -4
  83. package/dist/runtime/client/dev-toolbar/apps/audit/ui/audit-ui.js +2 -2
  84. package/dist/runtime/server/render/common.js +8 -0
  85. package/dist/runtime/server/render/instruction.d.ts +5 -5
  86. package/dist/runtime/server/render/server-islands.d.ts +1 -0
  87. package/dist/runtime/server/render/server-islands.js +29 -31
  88. package/dist/transitions/swap-functions.d.ts +1 -1
  89. package/dist/transitions/swap-functions.js +7 -6
  90. package/dist/types/public/config.d.ts +155 -98
  91. package/dist/types/public/internal.d.ts +1 -0
  92. package/dist/vite-plugin-astro-server/plugin.js +1 -1
  93. package/package.json +9 -5
  94. package/types/fonts.d.ts +4 -0
@@ -11,7 +11,7 @@ import { buildClientDirectiveEntrypoint } from "../core/client-directive/index.j
11
11
  import { mergeConfig } from "../core/config/index.js";
12
12
  import { validateConfigRefined } from "../core/config/validate.js";
13
13
  import { validateSetAdapter } from "../core/dev/adapter-validation.js";
14
- import { validateSessionConfig } from "../core/session.js";
14
+ import { getClientOutputDirectory } from "../prerender/utils.js";
15
15
  import { validateSupportedFeatures } from "./features-validation.js";
16
16
  async function withTakingALongTimeMsg({
17
17
  name,
@@ -310,7 +310,6 @@ async function runHookConfigDone({
310
310
  })
311
311
  });
312
312
  }
313
- validateSessionConfig(settings);
314
313
  }
315
314
  async function runHookServerSetup({
316
315
  config,
@@ -446,7 +445,7 @@ async function runHookBuildGenerated({
446
445
  }
447
446
  }
448
447
  async function runHookBuildDone({ settings, pages, routes, logger }) {
449
- const dir = settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
448
+ const dir = getClientOutputDirectory(settings);
450
449
  await fsMod.promises.mkdir(dir, { recursive: true });
451
450
  const integrationRoutes = routes.map(toIntegrationRouteData);
452
451
  for (const integration of settings.config.integrations) {
@@ -1,9 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
- import type { Logger } from '../core/logger/core.js';
3
- import type { AstroSettings } from '../types/astro.js';
4
2
  import type { SSRManifest } from '../types/public/index.js';
5
- export default function virtualModulePlugin({ settings, manifest, logger: _logger, }: {
6
- settings: AstroSettings;
3
+ export default function virtualModulePlugin({ manifest }: {
7
4
  manifest: SSRManifest;
8
- logger: Logger;
9
5
  }): Plugin;
@@ -1,15 +1,10 @@
1
- import { CantUseAstroConfigModuleError } from "../core/errors/errors-data.js";
2
1
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
3
2
  import { fromRoutingStrategy } from "../i18n/utils.js";
4
3
  const VIRTUAL_SERVER_ID = "astro:config/server";
5
4
  const RESOLVED_VIRTUAL_SERVER_ID = "\0" + VIRTUAL_SERVER_ID;
6
5
  const VIRTUAL_CLIENT_ID = "astro:config/client";
7
6
  const RESOLVED_VIRTUAL_CLIENT_ID = "\0" + VIRTUAL_CLIENT_ID;
8
- function virtualModulePlugin({
9
- settings,
10
- manifest,
11
- logger: _logger
12
- }) {
7
+ function virtualModulePlugin({ manifest }) {
13
8
  return {
14
9
  enforce: "pre",
15
10
  name: "astro-manifest-plugin",
@@ -22,20 +17,8 @@ function virtualModulePlugin({
22
17
  },
23
18
  load(id, opts) {
24
19
  if (id === RESOLVED_VIRTUAL_CLIENT_ID) {
25
- if (!settings.config.experimental.serializeConfig) {
26
- throw new AstroError({
27
- ...CantUseAstroConfigModuleError,
28
- message: CantUseAstroConfigModuleError.message(VIRTUAL_CLIENT_ID)
29
- });
30
- }
31
20
  return { code: serializeClientConfig(manifest) };
32
21
  } else if (id == RESOLVED_VIRTUAL_SERVER_ID) {
33
- if (!settings.config.experimental.serializeConfig) {
34
- throw new AstroError({
35
- ...CantUseAstroConfigModuleError,
36
- message: CantUseAstroConfigModuleError.message(VIRTUAL_SERVER_ID)
37
- });
38
- }
39
22
  if (!opts?.ssr) {
40
23
  throw new AstroError({
41
24
  ...AstroErrorData.ServerOnlyModule,
@@ -4,4 +4,8 @@ export declare function getPrerenderDefault(config: AstroConfig): boolean;
4
4
  /**
5
5
  * Returns the correct output directory of the SSR build based on the configuration
6
6
  */
7
- export declare function getOutputDirectory(settings: AstroSettings): URL;
7
+ export declare function getServerOutputDirectory(settings: AstroSettings): URL;
8
+ /**
9
+ * Returns the correct output directory of the client build based on the configuration
10
+ */
11
+ export declare function getClientOutputDirectory(settings: AstroSettings): URL;
@@ -2,14 +2,14 @@ import { getOutDirWithinCwd } from "../core/build/common.js";
2
2
  function getPrerenderDefault(config) {
3
3
  return config.output !== "server";
4
4
  }
5
- function getOutputDirectory(settings) {
6
- if (settings.buildOutput === "server") {
7
- return settings.config.build.server;
8
- } else {
9
- return getOutDirWithinCwd(settings.config.outDir);
10
- }
5
+ function getServerOutputDirectory(settings) {
6
+ return settings.buildOutput === "server" ? settings.config.build.server : getOutDirWithinCwd(settings.config.outDir);
7
+ }
8
+ function getClientOutputDirectory(settings) {
9
+ return settings.buildOutput === "server" ? settings.config.build.client : settings.config.outDir;
11
10
  }
12
11
  export {
13
- getOutputDirectory,
14
- getPrerenderDefault
12
+ getClientOutputDirectory,
13
+ getPrerenderDefault,
14
+ getServerOutputDirectory
15
15
  };
@@ -0,0 +1,6 @@
1
+ export interface Annotation {
2
+ file: string;
3
+ location: string;
4
+ }
5
+ export declare function getAnnotationsForElement(element: Element): Annotation | undefined;
6
+ export declare function processAnnotations(): void;
@@ -0,0 +1,27 @@
1
+ const ELEMENT_ANNOTATIONS = /* @__PURE__ */ new WeakMap();
2
+ function getAnnotationsForElement(element) {
3
+ return ELEMENT_ANNOTATIONS.get(element);
4
+ }
5
+ const ANNOTATION_MAP = {
6
+ "data-astro-source-file": "file",
7
+ "data-astro-source-loc": "location"
8
+ };
9
+ function extractAnnotations(element) {
10
+ const annotations = {};
11
+ for (const [attr, key] of Object.entries(ANNOTATION_MAP)) {
12
+ annotations[key] = element.getAttribute(attr);
13
+ }
14
+ for (const attr of Object.keys(ANNOTATION_MAP)) {
15
+ element.removeAttribute(attr);
16
+ }
17
+ return annotations;
18
+ }
19
+ function processAnnotations() {
20
+ for (const element of document.querySelectorAll(`[data-astro-source-file]`)) {
21
+ ELEMENT_ANNOTATIONS.set(element, extractAnnotations(element));
22
+ }
23
+ }
24
+ export {
25
+ getAnnotationsForElement,
26
+ processAnnotations
27
+ };
@@ -1,6 +1,7 @@
1
1
  import { settings } from "../../settings.js";
2
2
  import { positionHighlight } from "../utils/highlight.js";
3
3
  import { closeOnOutsideClick } from "../utils/window.js";
4
+ import { processAnnotations } from "./annotations.js";
4
5
  import { rulesCategories } from "./rules/index.js";
5
6
  import { DevToolbarAuditListItem } from "./ui/audit-list-item.js";
6
7
  import { DevToolbarAuditListWindow } from "./ui/audit-list-window.js";
@@ -22,8 +23,9 @@ var audit_default = {
22
23
  "astro-dev-toolbar-audit-window"
23
24
  );
24
25
  let hasCreatedUI = false;
26
+ auditWindow.popover = "";
25
27
  canvas.appendChild(auditWindow);
26
- await lint();
28
+ await run();
27
29
  let mutationDebounce;
28
30
  const observer = new MutationObserver(() => {
29
31
  if (mutationDebounce) {
@@ -34,7 +36,7 @@ var audit_default = {
34
36
  if ("requestIdleCallback" in window) {
35
37
  window.requestIdleCallback(
36
38
  async () => {
37
- lint().then(() => {
39
+ run().then(() => {
38
40
  if (showState) createAuditsUI();
39
41
  });
40
42
  },
@@ -42,7 +44,7 @@ var audit_default = {
42
44
  );
43
45
  } else {
44
46
  setTimeout(async () => {
45
- lint().then(() => {
47
+ run().then(() => {
46
48
  if (showState) createAuditsUI();
47
49
  });
48
50
  }, 150);
@@ -54,7 +56,7 @@ var audit_default = {
54
56
  observer.disconnect();
55
57
  });
56
58
  document.addEventListener("astro:after-swap", async () => {
57
- lint();
59
+ run();
58
60
  });
59
61
  document.addEventListener("astro:page-load", async () => {
60
62
  refreshLintPositions();
@@ -93,6 +95,10 @@ var audit_default = {
93
95
  canvas.appendChild(fragment);
94
96
  hasCreatedUI = true;
95
97
  }
98
+ async function run() {
99
+ processAnnotations();
100
+ await lint();
101
+ }
96
102
  async function lint() {
97
103
  if (audits.length > 0) {
98
104
  audits.forEach((audit) => {
@@ -4,6 +4,7 @@ import {
4
4
  createHighlight,
5
5
  getElementsPositionInDocument
6
6
  } from "../../utils/highlight.js";
7
+ import { getAnnotationsForElement } from "../annotations.js";
7
8
  import { resolveAuditRule } from "../rules/index.js";
8
9
  function truncate(val, maxLength) {
9
10
  return val.length > maxLength ? val.slice(0, maxLength - 1) + "…" : val;
@@ -50,8 +51,7 @@ function buildAuditTooltip(rule, element) {
50
51
  content: escapeHTML(message)
51
52
  }
52
53
  ];
53
- const elementFile = element.getAttribute("data-astro-source-file");
54
- const elementPosition = element.getAttribute("data-astro-source-loc");
54
+ const { file: elementFile, location: elementPosition } = getAnnotationsForElement(element) ?? {};
55
55
  if (elementFile) {
56
56
  const elementFileWithPosition = elementFile + (elementPosition ? ":" + elementPosition : "");
57
57
  tooltip.sections.push({
@@ -6,6 +6,7 @@ import {
6
6
  } from "../scripts.js";
7
7
  import { renderAllHeadContent } from "./head.js";
8
8
  import { isRenderInstruction } from "./instruction.js";
9
+ import { renderServerIslandRuntime } from "./server-islands.js";
9
10
  import { isSlotString } from "./slot.js";
10
11
  const Fragment = Symbol.for("astro:fragment");
11
12
  const Renderer = Symbol.for("astro:renderer");
@@ -48,6 +49,13 @@ function stringifyChunk(result, chunk) {
48
49
  }
49
50
  return "";
50
51
  }
52
+ case "server-island-runtime": {
53
+ if (result._metadata.hasRenderedServerIslandRuntime) {
54
+ return "";
55
+ }
56
+ result._metadata.hasRenderedServerIslandRuntime = true;
57
+ return renderServerIslandRuntime();
58
+ }
51
59
  default: {
52
60
  throw new Error(`Unknown chunk type: ${chunk.type}`);
53
61
  }
@@ -18,9 +18,9 @@ export type RendererHydrationScriptInstruction = {
18
18
  export type MaybeRenderHeadInstruction = {
19
19
  type: 'maybe-head';
20
20
  };
21
- export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction | RendererHydrationScriptInstruction;
22
- export declare function createRenderInstruction(instruction: RenderDirectiveInstruction): RenderDirectiveInstruction;
23
- export declare function createRenderInstruction(instruction: RendererHydrationScriptInstruction): RendererHydrationScriptInstruction;
24
- export declare function createRenderInstruction(instruction: RenderHeadInstruction): RenderHeadInstruction;
25
- export declare function createRenderInstruction(instruction: MaybeRenderHeadInstruction): MaybeRenderHeadInstruction;
21
+ export type ServerIslandRuntimeInstruction = {
22
+ type: 'server-island-runtime';
23
+ };
24
+ export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction | RendererHydrationScriptInstruction | ServerIslandRuntimeInstruction;
25
+ export declare function createRenderInstruction<T extends RenderInstruction>(instruction: T): T;
26
26
  export declare function isRenderInstruction(chunk: any): chunk is RenderInstruction;
@@ -3,3 +3,4 @@ import type { RenderInstance } from './common.js';
3
3
  import { type ComponentSlots } from './slot.js';
4
4
  export declare function containsServerDirective(props: Record<string | number, any>): boolean;
5
5
  export declare function renderServerIsland(result: SSRResult, _displayName: string, props: Record<string | number, any>, slots: ComponentSlots): RenderInstance;
6
+ export declare const renderServerIslandRuntime: () => any;
@@ -1,5 +1,7 @@
1
1
  import { encryptString } from "../../../core/encryption.js";
2
+ import { markHTMLString } from "../escape.js";
2
3
  import { renderChild } from "./any.js";
4
+ import { createRenderInstruction } from "./instruction.js";
3
5
  import { renderSlotToString } from "./slot.js";
4
6
  const internalProps = /* @__PURE__ */ new Set([
5
7
  "server:component-path",
@@ -43,6 +45,7 @@ function renderServerIsland(result, _displayName, props, slots) {
43
45
  delete props[key2];
44
46
  }
45
47
  }
48
+ destination.write(createRenderInstruction({ type: "server-island-runtime" }));
46
49
  destination.write("<!--[if astro]>server-island-start<![endif]-->");
47
50
  const renderedSlots = {};
48
51
  for (const name in slots) {
@@ -70,13 +73,9 @@ function renderServerIsland(result, _displayName, props, slots) {
70
73
  `<link rel="preload" as="fetch" href="${serverIslandUrl}" crossorigin="anonymous">`
71
74
  );
72
75
  }
73
- destination.write(`<script async type="module" data-astro-rerun data-island-id="${hostId}">
74
- let script = document.querySelector('script[data-island-id="${hostId}"]');
75
-
76
- ${useGETRequest ? (
76
+ destination.write(`<script type="module" data-astro-rerun data-island-id="${hostId}">${useGETRequest ? (
77
77
  // GET request
78
- `let response = await fetch('${serverIslandUrl}');
79
- `
78
+ `let response = await fetch('${serverIslandUrl}');`
80
79
  ) : (
81
80
  // POST request
82
81
  `let data = {
@@ -84,38 +83,37 @@ ${useGETRequest ? (
84
83
  encryptedProps: ${safeJsonStringify(propsEncrypted)},
85
84
  slots: ${safeJsonStringify(renderedSlots)},
86
85
  };
87
-
88
86
  let response = await fetch('${serverIslandUrl}', {
89
87
  method: 'POST',
90
88
  body: JSON.stringify(data),
91
- });
92
- `
89
+ });`
93
90
  )}
94
- if (script) {
95
- if(
96
- response.status === 200
97
- && response.headers.has('content-type')
98
- && response.headers.get('content-type').split(";")[0].trim() === 'text/html') {
99
- let html = await response.text();
100
-
101
- // Swap!
102
- while(script.previousSibling &&
103
- script.previousSibling.nodeType !== 8 &&
104
- script.previousSibling.data !== '[if astro]>server-island-start<![endif]') {
105
- script.previousSibling.remove();
106
- }
107
- script.previousSibling?.remove();
108
-
109
- let frag = document.createRange().createContextualFragment(html);
110
- script.before(frag);
111
- }
112
- script.remove(); // Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
113
- }
114
- </script>`);
91
+ replaceServerIsland('${hostId}', response);</script>`);
115
92
  }
116
93
  };
117
94
  }
95
+ const renderServerIslandRuntime = () => markHTMLString(
96
+ `
97
+ <script>
98
+ async function replaceServerIsland(id, r) {
99
+ let s = document.querySelector(\`script[data-island-id="\${id}"]\`);
100
+ // If there's no matching script, or the request fails then return
101
+ if (!s || r.status !== 200 || r.headers.get('content-type')?.split(';')[0].trim() !== 'text/html') return;
102
+ // Load the HTML before modifying the DOM in case of errors
103
+ let html = await r.text();
104
+ // Remove any placeholder content before the island script
105
+ while (s.previousSibling && s.previousSibling.nodeType !== 8 && s.previousSibling.data !== '[if astro]>server-island-start<![endif]')
106
+ s.previousSibling.remove();
107
+ s.previousSibling?.remove();
108
+ // Insert the new HTML
109
+ s.before(document.createRange().createContextualFragment(html));
110
+ // Remove the script. Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
111
+ s.remove();
112
+ }
113
+ </script>`.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("//")).join(" ")
114
+ );
118
115
  export {
119
116
  containsServerDirective,
120
- renderServerIsland
117
+ renderServerIsland,
118
+ renderServerIslandRuntime
121
119
  };
@@ -5,7 +5,7 @@ export type SavedFocus = {
5
5
  };
6
6
  export declare function detectScriptExecuted(script: HTMLScriptElement): boolean;
7
7
  export declare function deselectScripts(doc: Document): void;
8
- export declare function swapRootAttributes(doc: Document): void;
8
+ export declare function swapRootAttributes(newDoc: Document): void;
9
9
  export declare function swapHeadElements(doc: Document): void;
10
10
  export declare function swapBodyElement(newElement: Element, oldElement: Element): void;
11
11
  export declare const saveFocus: () => (() => void);
@@ -1,4 +1,5 @@
1
1
  const PERSIST_ATTR = "data-astro-transition-persist";
2
+ const NON_OVERRIDABLE_ASTRO_ATTRS = ["data-astro-transition", "data-astro-transition-fallback"];
2
3
  const scriptsAlreadyRan = /* @__PURE__ */ new Set();
3
4
  function detectScriptExecuted(script) {
4
5
  const key = script.src ? new URL(script.src, location.href).href : script.textContent;
@@ -17,13 +18,13 @@ function deselectScripts(doc) {
17
18
  }
18
19
  }
19
20
  }
20
- function swapRootAttributes(doc) {
21
- const html = document.documentElement;
22
- const astroAttributes = [...html.attributes].filter(
23
- ({ name }) => (html.removeAttribute(name), name.startsWith("data-astro-"))
21
+ function swapRootAttributes(newDoc) {
22
+ const currentRoot = document.documentElement;
23
+ const nonOverridableAstroAttributes = [...currentRoot.attributes].filter(
24
+ ({ name }) => (currentRoot.removeAttribute(name), NON_OVERRIDABLE_ASTRO_ATTRS.includes(name))
24
25
  );
25
- [...doc.documentElement.attributes, ...astroAttributes].forEach(
26
- ({ name, value }) => html.setAttribute(name, value)
26
+ [...newDoc.documentElement.attributes, ...nonOverridableAstroAttributes].forEach(
27
+ ({ name, value }) => currentRoot.setAttribute(name, value)
27
28
  );
28
29
  }
29
30
  function swapHeadElements(doc) {