From ff70ab1b76f0fea051c932bb2b8eac948ac2de96 Mon Sep 17 00:00:00 2001 From: 7nik Date: Tue, 17 Feb 2026 12:11:05 +0200 Subject: [PATCH] fix: locate Rollup annontaion friendly to JS downgraders (#17724) Closes #17722 Looks like after downgrading `?.`, `/* @__PURE__ */` may happen in an invalid location. --------- Co-authored-by: Simon H <5968653+dummdidumm@users.noreply.github.com> --- .changeset/icy-otters-fall.md | 5 +++++ packages/svelte/src/internal/client/constants.js | 5 ++++- packages/svelte/src/internal/client/dom/reconciler.js | 10 +++++----- 3 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .changeset/icy-otters-fall.md 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) {