diff --git a/src/dom_components/model/Component.ts b/src/dom_components/model/Component.ts index ae4a0d09c..a45a42a6d 100644 --- a/src/dom_components/model/Component.ts +++ b/src/dom_components/model/Component.ts @@ -1804,6 +1804,23 @@ export default class Component extends StyleableModel { 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}