33 *
44 * Handles validation and state management for GDPR consent checkboxes in forms
55 */
6+ import { LitElement } from 'lit'
67import { addScriptBreadcrumb , ClientScriptError } from '@components/scripts/errors'
78import { handleScriptError } from '@components/scripts/errors/handler'
89import { defineCustomElement } from '@components/scripts/utils'
@@ -26,7 +27,9 @@ const COMPONENT_TAG_NAME = 'consent-checkbox' as const
2627const READY_EVENT = 'consent-checkbox:ready'
2728const COMPONENT_SCRIPT_NAME = 'ConsentCheckboxElement'
2829
29- export class ConsentCheckboxElement extends HTMLElement {
30+ export class ConsentCheckboxElement extends LitElement {
31+ static registeredName = COMPONENT_TAG_NAME
32+
3033 private domReadyHandler : ( ( ) => void ) | null = null
3134 private checkbox : HTMLInputElement | null = null
3235 private container : HTMLDivElement | null = null
@@ -42,7 +45,12 @@ export class ConsentCheckboxElement extends HTMLElement {
4245
4346 public isInitialized = false
4447
45- connectedCallback ( ) : void {
48+ protected override createRenderRoot ( ) : HTMLElement {
49+ return this
50+ }
51+
52+ override connectedCallback ( ) : void {
53+ super . connectedCallback ( )
4654 if ( typeof document === 'undefined' || this . isInitialized ) {
4755 return
4856 }
@@ -60,7 +68,8 @@ export class ConsentCheckboxElement extends HTMLElement {
6068 this . initialize ( )
6169 }
6270
63- disconnectedCallback ( ) : void {
71+ override disconnectedCallback ( ) : void {
72+ super . disconnectedCallback ( )
6473 this . cleanupDomReadyHandler ( )
6574 this . cleanupListeners ( )
6675 this . isInitialized = false
@@ -363,8 +372,10 @@ export const registerConsentCheckboxWebComponent = (tagName: string = COMPONENT_
363372 defineCustomElement ( tagName , ConsentCheckboxElement )
364373}
365374
375+ export const registerWebComponent = registerConsentCheckboxWebComponent
376+
366377export const webComponentModule : WebComponentModule < ConsentCheckboxElement > = {
367378 registeredName : COMPONENT_TAG_NAME ,
368379 componentCtor : ConsentCheckboxElement ,
369- registerWebComponent : registerConsentCheckboxWebComponent ,
380+ registerWebComponent,
370381}
0 commit comments