Skip to content

Commit edf4a7b

Browse files
authored
Add methods for setting component inner text and HTML content (#4)
2 parents d439fa0 + 411d7f0 commit edf4a7b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ElementComponent.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,22 @@ export abstract class ElementComponent<T extends Element> {
129129
return this;
130130
}
131131

132+
/**
133+
* Set text content
134+
*/
135+
public text(text: string) {
136+
this.element.textContent = text;
137+
return this;
138+
}
139+
140+
/**
141+
* Set inner HTML
142+
*/
143+
public html(html: string) {
144+
this.element.innerHTML = html;
145+
return this;
146+
}
147+
132148
/**
133149
* Set element property
134150
* @param name property name

0 commit comments

Comments
 (0)