fix(demotools): update DeesDemoWrapper to handle multiple slotted elements in runAfterRender callback
This commit is contained in:
@ -3,7 +3,7 @@ import { DeesElement, customElement, html, css, property, type TemplateResult }
|
||||
@customElement('dees-demowrapper')
|
||||
export class DeesDemoWrapper extends DeesElement {
|
||||
@property({ attribute: false })
|
||||
public runAfterRender: (element: HTMLElement) => void | Promise<void>;
|
||||
public runAfterRender: (children: HTMLCollection) => void | Promise<void>;
|
||||
|
||||
public static styles = [
|
||||
css`
|
||||
@ -25,14 +25,12 @@ export class DeesDemoWrapper extends DeesElement {
|
||||
// Wait a bit for slotted content to render
|
||||
await new Promise(resolve => setTimeout(resolve, 50));
|
||||
|
||||
// Find the first element child (excluding text nodes)
|
||||
// Get all slotted elements
|
||||
const slottedElements = this.children;
|
||||
if (slottedElements.length > 0 && this.runAfterRender) {
|
||||
const firstElement = slottedElements[0] as HTMLElement;
|
||||
|
||||
// Call the runAfterRender function with the element
|
||||
// Call the runAfterRender function with all slotted elements
|
||||
try {
|
||||
await this.runAfterRender(firstElement);
|
||||
await this.runAfterRender(slottedElements);
|
||||
} catch (error) {
|
||||
console.error('Error in runAfterRender:', error);
|
||||
}
|
||||
|
Reference in New Issue
Block a user