| 52 | { addInitializer }: ClassDecoratorContext<ClassComponent> |
| 53 | ) => { |
| 54 | class RendererComponent |
| 55 | extends (Class as ClassComponent) |
| 56 | implements WebCell |
| 57 | { |
| 58 | declare props: WebCellProps; |
| 59 | |
| 60 | internals = this.tagName.includes('-') |
| 61 | ? this.attachInternals() |
| 62 | : undefined; |
| 63 | renderer = new DOMRenderer(); |
| 64 | |
| 65 | get root(): ParentNode { |
| 66 | return this.shadowRoot || this.internals.shadowRoot || this; |
| 67 | } |
| 68 | mounted = false; |
| 69 | declare mountedCallback?: () => any; |
| 70 | |
| 71 | constructor() { |
| 72 | super(); |
| 73 | |
| 74 | if (meta.mode && !this.internals?.shadowRoot) |
| 75 | this.attachShadow(meta as ShadowRootInit); |
| 76 | } |
| 77 | |
| 78 | async connectedCallback() { |
| 79 | const { mode } = meta; |
| 80 | const renderChildren = !(mode != null); |
| 81 | |
| 82 | const { root } = this, |
| 83 | events = eventMap.get(this) || []; |
| 84 | |
| 85 | for (const { type, selector, handler } of events) { |
| 86 | if (renderChildren && /^:host/.test(selector)) |
| 87 | console.warn( |
| 88 | `[WebCell] DOM Event delegation of "${selector}" won't work if you don't invoke "this.attachShadow()" manually.` |
| 89 | ); |
| 90 | root.addEventListener(type, handler); |
| 91 | } |
| 92 | |
| 93 | super['connectedCallback']?.(); |
| 94 | |
| 95 | if (this.mounted) return; |
| 96 | |
| 97 | await this.update(); |
| 98 | |
| 99 | this.mounted = true; |
| 100 | this.mountedCallback?.(); |
| 101 | } |
| 102 | |
| 103 | declare render?: () => VNode; |
| 104 | declare updatedCallback?: () => any; |
| 105 | |
| 106 | protected updateDOM(content: VNode) { |
| 107 | const result = this.renderer.render( |
| 108 | content, |
| 109 | this.root, |
| 110 | meta.renderMode as 'async' |
| 111 | ); |
nothing calls this directly
no outgoing calls
no test coverage detected