fix(html): HTML SSR safety and sandbox skin chunking (#1155)

This commit is contained in:
Sam Potts
2026-03-31 07:26:08 +11:00
committed by GitHub
parent 3fc6cbb9bc
commit 0433722ee4
15 changed files with 109 additions and 32 deletions
@@ -1,7 +1,11 @@
import { describe, expect, it } from 'vitest';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { safeDefine } from '../safe-define';
describe('safeDefine', () => {
afterEach(() => {
vi.unstubAllGlobals();
});
it('registers a custom element', () => {
class TestElement extends HTMLElement {
static tagName = 'test-sd-register';
@@ -33,4 +37,14 @@ describe('safeDefine', () => {
safeDefine(Replacement);
expect(customElements.get('test-sd-no-replace')).toBe(Original);
});
it('does nothing when customElements is unavailable', () => {
vi.stubGlobal('customElements', undefined);
class TestElement extends HTMLElement {
static tagName = 'test-sd-ssr';
}
expect(() => safeDefine(TestElement)).not.toThrow();
});
});