diff --git a/.changeset/icy-otters-fall.md b/.changeset/icy-otters-fall.md new file mode 100644 index 0000000000..b15c282ca4 --- /dev/null +++ b/.changeset/icy-otters-fall.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: locate Rollup annontaion friendly to JS downgraders diff --git a/packages/svelte/src/internal/client/constants.js b/packages/svelte/src/internal/client/constants.js index 7b118a5b5f..3525539f1d 100644 --- a/packages/svelte/src/internal/client/constants.js +++ b/packages/svelte/src/internal/client/constants.js @@ -67,7 +67,10 @@ export const STALE_REACTION = new (class StaleReactionError extends Error { message = 'The reaction that called `getAbortSignal()` was re-run or destroyed'; })(); -export const IS_XHTML = /* @__PURE__ */ globalThis.document?.contentType?.includes('xml') ?? false; +export const IS_XHTML = + // We gotta write it like this because after downleveling the pure comment may end up in the wrong location + !!globalThis.document?.contentType && + /* @__PURE__ */ globalThis.document.contentType.includes('xml'); export const ELEMENT_NODE = 1; export const TEXT_NODE = 3; export const COMMENT_NODE = 8; diff --git a/packages/svelte/src/internal/client/dom/reconciler.js b/packages/svelte/src/internal/client/dom/reconciler.js index 1f4750ce8f..0ceebd3337 100644 --- a/packages/svelte/src/internal/client/dom/reconciler.js +++ b/packages/svelte/src/internal/client/dom/reconciler.js @@ -2,15 +2,15 @@ import { create_element } from './operations.js'; -const policy = /* @__PURE__ */ globalThis?.window?.trustedTypes?.createPolicy( - 'svelte-trusted-html', - { +const policy = + // We gotta write it like this because after downleveling the pure comment may end up in the wrong location + globalThis?.window?.trustedTypes && + /* @__PURE__ */ globalThis.window.trustedTypes.createPolicy('svelte-trusted-html', { /** @param {string} html */ createHTML: (html) => { return html; } - } -); + }); /** @param {string} html */ function create_trusted_html(html) {