From 2aad61fcab1e5532c45f0e3263abde83d9e71357 Mon Sep 17 00:00:00 2001 From: Adam Midlik Date: Wed, 1 Jul 2026 12:54:35 +0100 Subject: [PATCH 1/2] nightingale-scrollbox: relax DOMPurify sanitization to allow custom elements --- .../nightingale-scrollbox/src/nightingale-scrollbox-item.ts | 2 +- .../19.NightingaleScrollbox/NightingaleScrollbox.stories.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/nightingale-scrollbox/src/nightingale-scrollbox-item.ts b/packages/nightingale-scrollbox/src/nightingale-scrollbox-item.ts index d71d7b41..8e90e302 100644 --- a/packages/nightingale-scrollbox/src/nightingale-scrollbox-item.ts +++ b/packages/nightingale-scrollbox/src/nightingale-scrollbox-item.ts @@ -86,7 +86,7 @@ export class NightingaleScrollboxItem extends NightingaleElement { private setContent(content: string | null | undefined) { if (content === undefined || content === null) return; - this.innerHTML = DOMPurify.sanitize(content); + this.innerHTML = DOMPurify.sanitize(content, { CUSTOM_ELEMENT_HANDLING: { tagNameCheck: /.*/, attributeNameCheck: /.*/, allowCustomizedBuiltInElements: true } }); } /** Set or remove "onRegister" callback function. Also run this callback function if the item is already registered (i.e. in "new", "visible", or "hidden" state). */ diff --git a/stories/19.NightingaleScrollbox/NightingaleScrollbox.stories.ts b/stories/19.NightingaleScrollbox/NightingaleScrollbox.stories.ts index 31c84716..8694c54c 100644 --- a/stories/19.NightingaleScrollbox/NightingaleScrollbox.stories.ts +++ b/stories/19.NightingaleScrollbox/NightingaleScrollbox.stories.ts @@ -3,7 +3,8 @@ import { html } from "lit-html"; import { range } from "lodash-es"; import "../../packages/nightingale-navigation/src/index"; import "../../packages/nightingale-scrollbox/src/index"; -import { NightingaleScrollbox, NightingaleScrollboxItem } from "../../packages/nightingale-scrollbox/src/index"; +import type { NightingaleScrollbox, NightingaleScrollboxItem } from "../../packages/nightingale-scrollbox/src/index"; +import "../../packages/nightingale-track/src/index"; export default { From 57a0d3c1ab1063ae4870c68711ddd1d921a84e66 Mon Sep 17 00:00:00 2001 From: Adam Midlik Date: Wed, 1 Jul 2026 13:18:43 +0100 Subject: [PATCH 2/2] nightingale-scrollbox: avoid double unregistering error when the whole scrollbox is disconnected --- packages/nightingale-scrollbox/src/nightingale-scrollbox.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nightingale-scrollbox/src/nightingale-scrollbox.ts b/packages/nightingale-scrollbox/src/nightingale-scrollbox.ts index b74325ee..66951c3b 100644 --- a/packages/nightingale-scrollbox/src/nightingale-scrollbox.ts +++ b/packages/nightingale-scrollbox/src/nightingale-scrollbox.ts @@ -88,9 +88,9 @@ export class NightingaleScrollbox extends NightingaleElement { unregister: () => this.unregister(item), }; } - /** Remove a scrollbox item and run "onUnregister" callback on it. This method is called automatically when a `nightingale-scrollbox-item` element is removed from the `nightingale-scrollbox` element. */ + /** Remove a scrollbox item and run "onUnregister" callback on it. Do nothing if the item is not registered. This method is called automatically when a `nightingale-scrollbox-item` element is removed from the `nightingale-scrollbox` element. */ unregister(item: NightingaleScrollboxItem) { - if (!this._items.has(item)) throw new Error(`Cannot unregister item ${item} because it is not registered.`) + if (!this._items.has(item)) return; this._items.delete(item); this.observer?.unobserve(item); item.unregister();