You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For reference, I'm using dom/v2 with go1.16.6 to build WASM client for a web project.
I have a case when I parse some arbitrary HTML from the server and add individual elements to DOM based on this. I call SetInnerHTML on some temporary element and then add children one by one. However HTML has whitespaces in it, so returned node may be a text one.
...newCommentsList:=dom.GetWindow().Document().CreateElement("div")
newCommentsList.SetInnerHTML(resp.HTML)
...for_, commentNode:=rangenewCommentsList.ChildNodes() {
if_, ok:=commentNode.(*dom.Text); ok {
//if commentNode.NodeType() == 3 { // or like thiscontinue
}
...commentsTop.ParentElement().InsertBefore(commentNode, commentsTop.NextElementSibling())
}
...
For reference, I'm using
dom/v2
withgo1.16.6
to build WASM client for a web project.I have a case when I parse some arbitrary HTML from the server and add individual elements to DOM based on this. I call
SetInnerHTML
on some temporary element and then add children one by one. However HTML has whitespaces in it, so returned node may be a text one.I could have avoided checking against node type if I had
Children
method:https://developer.mozilla.org/en-US/docs/Web/API/Element/children. Other
*Element
methods, such asParentElement
orNextElementSibling
works fine for this purpose.The text was updated successfully, but these errors were encountered: