fix: use TrustedHTML to test for customizable <select> support, where necessary (#17743)

https://github.com/sveltejs/svelte/pull/17701#issuecomment-3899991195

no test because jsdom
pull/17747/head
Rich Harris 5 days ago committed by GitHub
parent cbf4e246fc
commit 696d97ff3e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: use TrustedHTML to test for customizable <select> support, where necessary

@ -1,5 +1,6 @@
import { hydrating, reset, set_hydrate_node, set_hydrating } from '../hydration.js';
import { create_comment, create_element } from '../operations.js';
import { create_trusted_html } from '../reconciler.js';
import { attach } from './attachments.js';
/** @type {boolean | null} */
@ -14,7 +15,7 @@ let supported = null;
function is_supported() {
if (supported === null) {
var select = create_element('select');
select.innerHTML = '<option><span>t</span></option>';
select.innerHTML = create_trusted_html('<option><span>t</span></option>');
supported = /** @type {Element} */ (select.firstChild)?.firstChild?.nodeType === 1;
}

@ -11,7 +11,7 @@ const policy =
});
/** @param {string} html */
function create_trusted_html(html) {
export function create_trusted_html(html) {
return /** @type {string} */ (policy?.createHTML(html) ?? html);
}

Loading…
Cancel
Save