Skip to content

Commit 4358e44

Browse files
committed
ElementComponent#html() is now a string literal tag fn to append HTML
For the old behaviour, that effectively replaces the inner HTML, first call `.empty()`.
1 parent b6cf69c commit 4358e44

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/ElementComponent.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,6 @@ export abstract class ElementComponent<T extends Element> extends NodeComponent<
127127
return this;
128128
}
129129

130-
/**
131-
* Set inner HTML
132-
*/
133-
public html(html: string) {
134-
this.node.innerHTML = html;
135-
return this;
136-
}
137-
138130
/**
139131
* Template literal tag function that accepts HTML code with components in a
140132
* string literal and returns a {@link DocumentComponent}
@@ -152,6 +144,14 @@ export abstract class ElementComponent<T extends Element> extends NodeComponent<
152144
return doc;
153145
}
154146

147+
/**
148+
* Append HTML
149+
* @example component.html`<div>${component}</div>`
150+
*/
151+
public html(strings: TemplateStringsArray, ...components: NodeComponent<any>[]): this {
152+
return this.append(this.tag(strings, ...components));
153+
}
154+
155155
/**
156156
* Set element property
157157
* @param name property name

0 commit comments

Comments
 (0)