Skip to content

Commit c863777

Browse files
committed
add NodeComponent#context()
1 parent 70cec98 commit c863777

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/NodeComponent.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ export abstract class NodeComponent<T extends Node> {
3333
this.node = node;
3434
}
3535

36+
/**
37+
* Run a function in the context of this component
38+
* @param fn Provides this component as the first argument and `this`.
39+
*/
40+
public context(fn: (this: this, component: this) => this): this {
41+
fn.call(this, this);
42+
return this;
43+
}
44+
3645
/**
3746
* Insert component after the last child
3847
*/

0 commit comments

Comments
 (0)