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>
pull/17217/merge
7nik 12 hours ago committed by GitHub
parent 82265f1496
commit ff70ab1b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: locate Rollup annontaion friendly to JS downgraders

@ -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;

@ -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) {

Loading…
Cancel
Save