Skip to content

Commit a96d0e7

Browse files
committed
improve ElementComponent.html() documentation
1 parent 4358e44 commit a96d0e7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/ElementComponent.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,18 @@ export abstract class ElementComponent<T extends Element> extends NodeComponent<
145145
}
146146

147147
/**
148-
* Append HTML
149-
* @example component.html`<div>${component}</div>`
148+
* Append HTML.
149+
*
150+
* Any components (provided as `${...}` inside the HTML string literal)
151+
* remain fully functional and are appended (not just as HTML).
152+
* @example
153+
* component.html`<div>${new Component("button")
154+
* .text("Click me")
155+
* .on("click", () => console.log("clicked"))
156+
* }</div>`
157+
* // Event listeners etc. are preserved.
158+
* // Note the lack of parentheses.
159+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals Template literals (Template strings) - MDN
150160
*/
151161
public html(strings: TemplateStringsArray, ...components: NodeComponent<any>[]): this {
152162
return this.append(this.tag(strings, ...components));

0 commit comments

Comments
 (0)