Allow passing of nodes directly to UIFragment.html

This commit is contained in:
Tony Garnock-Jones 2022-01-24 09:10:20 +01:00
parent fb83b0e524
commit 431a7f49b0
1 changed files with 5 additions and 2 deletions

View File

@ -501,8 +501,11 @@ export class Anchor {
return new Anchor({ fragmentId: this.fragmentId + '__' + extn });
}
html(selector: string, html: HtmlFragments, orderBy: NodeOrderKey = ''): ReturnType<typeof P.UIFragment> {
return P.UIFragment(this.fragmentId, selector, embed(create ({ data: html.nodes() })), orderBy);
html(selector: string, html: HtmlFragments | Array<ChildNode>, orderBy: NodeOrderKey = ''): ReturnType<typeof P.UIFragment> {
if (!Array.isArray(html)) {
html = html.nodes();
}
return P.UIFragment(this.fragmentId, selector, embed(create ({ data: html })), orderBy);
}
}