From bdd8c09cc7d5c076a2839ecd79bb67d23ba55030 Mon Sep 17 00:00:00 2001 From: William Wong Date: Sat, 26 Oct 2024 03:06:29 +0000 Subject: [PATCH] Add static --- .../customElements/registerCodeBlockCopyButton.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/component/src/providers/CustomElements/customElements/registerCodeBlockCopyButton.ts b/packages/component/src/providers/CustomElements/customElements/registerCodeBlockCopyButton.ts index 20fc34da9a..7cdc79d935 100644 --- a/packages/component/src/providers/CustomElements/customElements/registerCodeBlockCopyButton.ts +++ b/packages/component/src/providers/CustomElements/customElements/registerCodeBlockCopyButton.ts @@ -110,8 +110,16 @@ export default function registerCodeBlockCopyButton(hash: string): string { // Allowed tag names are specified here, https://developer.mozilla.org/en-US/docs/Web/API/CustomElementRegistry/define#valid_custom_element_names const name = `webchat-${hash}--code-block-copy-button`; - // One class can only be registered with one tag name. Must be 1:1 relationship. - customElements.define(name, class extends CodeBlockCopyButtonElement {}); + customElements.define( + name, + // Using anonymous class because one class can only be registered with one tag name. + // Web Components enforce 1:1 relationship. + class extends CodeBlockCopyButtonElement { + static get observedAttributes(): readonly ObservedAttributes[] { + return observedAttributes; + } + } + ); return name; }