Browse Source

Add `Component.forEachChild` method

pull/5649/head
Artur Arseniev 3 years ago
parent
commit
7a9703b6fb
  1. 17
      src/dom_components/model/Component.ts

17
src/dom_components/model/Component.ts

@ -1804,6 +1804,23 @@ export default class Component extends StyleableModel<ComponentProperties> {
return this;
}
/**
* Execute a callback function on all inner child components.
* @param {Function} clb Callback function, the child component is passed as an argument
* @example
* component.forEachChild(child => {
* console.log(child)
* })
*/
forEachChild(clb: (child: Component) => void) {
if (isFunction(clb)) {
this.components().forEach(child => {
clb(child);
child.forEachChild(clb);
});
}
}
/**
* Remove the component
* @return {this}

Loading…
Cancel
Save