Skip to content

How to add raw HTML child in isomorphic components (van & van-plate)? #162

Answered by Tao-VanJS
btakita asked this question in Q&A
Discussion options

You must be logged in to vote

Mini-Van 0.5.3 was released. The 0.5.3 release added support of Node type (derived from Element["childNode"]) as parameters of tag functions. Thus with this release, DocumentFragment (which is a subtype of Node) becomes valid parameter of tag functions.

For sample usage, you can refer to this test case:

fragment: () => {
  const fragment = new DocumentFragment
  fragment.append(div(1), div(2))
  const dom = div(div(0), fragment)
  assertEq(dom.outerHTML, "<div><div>0</div><div>1</div><div>2</div></div>")
}

Let me know if it's helpful for your use cases.

The solution is a little bit hacky, though. Future changes of childNode implementation in the 3rd party DOM library you're using might br…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
6 replies
@btakita
Comment options

@Tao-VanJS
Comment options

@Tao-VanJS
Comment options

@btakita
Comment options

@Tao-VanJS
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by Tao-VanJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants