This repository was archived by the owner on May 25, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11## v0.0.0-beta.3 <- current
22
33## v0.0.0
4- Delete deletes the node without connecting sibling nodes.
5- * Delete
6-
74QuerySelector takes attribute name and regexp for the value and returns the first node that matches the regexp.
85* QuerySelector
96
Original file line number Diff line number Diff line change @@ -229,6 +229,7 @@ func (node *Node) RemoveNode() {
229229
230230 node .previousNode = nil
231231 node .nextNode = nil
232+ node .parentNode = nil
232233
233234 node .rwMutex .Unlock ()
234235
@@ -239,9 +240,13 @@ func (node *Node) RemoveNode() {
239240 nextNode .SetPreviousNode (previousNode )
240241 }
241242
242- if nextNode != nil {
243+ if nextNode != nil && previousNode == nil {
243244 nextNode .setParentNode (parentNode )
244245 }
246+
247+ if parentNode != nil {
248+ parentNode .childNode = nextNode
249+ }
245250}
246251
247252// IsTextNode returns a boolean value indicating node is a text node or not.
Original file line number Diff line number Diff line change @@ -86,4 +86,27 @@ func TestAppendTextAndInnerText(t *testing.T){
8686 t .Fatal (body .GetInnerText (), " != " , h1 .GetChildNode ().GetText () + p .GetChildNode ().GetText ())
8787 }
8888
89+ }
90+
91+ func TestRemoveNode (t * testing.T ){
92+ article := GoHtml .CreateNode ("article" )
93+
94+ h1 := GoHtml .CreateNode ("h1" )
95+ h1 .AppendText ("This is a heading." )
96+ article .AppendChild (h1 )
97+
98+ article .AppendChild (GoHtml .CreateNode (GoHtml .Br ))
99+
100+ p := GoHtml .CreateNode ("p" )
101+ p .AppendText ("this is a paragraph." )
102+ article .AppendChild (p )
103+
104+ h1 .RemoveNode ()
105+
106+ if article .GetChildNode ().GetTagName () != GoHtml .Br {
107+ t .Fatal ("Unexpected tag. " , article .GetChildNode ().GetTagName ())
108+ return
109+ }else if p .GetParent () != article {
110+ t .Fatal ("Unexpected parent." )
111+ }
89112}
You can’t perform that action at this time.
0 commit comments