Clarifying what "children" are in backdraftjs

8 Views Asked by At

What are children of a backdraftjs component? I would have expected them to be whatever's in the top level of the tree but that is not the case.

1

There are 1 best solutions below

0
On

Here is a component:

export class MarxBrothers {
    bdElements() {
        return e.div(
            e.span('groucho'),
            e.span('harpo'),
            e.span(
                e.div(
                    e.span(
                        e(Button, {label: 'chico'})
                    ),
                ),
            ),
            e(Button, {label: 'zeppo'})
        );
    }
}

Where the component is this...

  • this.children is ONLY the two Button components, 'chico' and 'zeppo'. Regular dom elements like span or div are not included in children, and children seems to dig down through the tree until it reaches a component.

  • this.delChildren() deletes the two buttons and leaves the rest of the content.