Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/net/html: Add some additional functionality to the Node type? #16587

Closed
kminehart opened this issue Aug 3, 2016 · 1 comment
Closed

x/net/html: Add some additional functionality to the Node type? #16587

kminehart opened this issue Aug 3, 2016 · 1 comment

Comments

@kminehart
Copy link

kminehart commented Aug 3, 2016

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?

1.6.3 linux/amd64

  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/kminehart/Work/go"
GORACE=""
GOROOT="/usr/lib/go"
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"

Not sure questions 3, 4 and 5 are relevant.

I'd like to make a pull request but I'd also like some discussion beforehand so I don't waste anyone's time.

I think some added functionality to the x/net/html would be nice.

For example, several of the functions on the Node type require that a node not be attached before it is used, like

func (n *Node) InsertBefore(newChild, oldChild *Node)

which will panic if a node has a parent or siblings. Handling this is fairly straightforward, but there are some unexpected nuances that would be easily solved (and universally avoided) with a function like

func (n *Node) Detach()

In order to fix InsertBefore's panic, one could simply set "newChild.NextSibling", "newChild.PrevSibling", "newChild.Parent" to "nil". This would break the Linked Tree because its next and previous siblings, as well as its parent, would still point to that node. So everyone would essentially have to make their own "Detach" function anyways if they plan on moving nodes around in a tree.

So I'm proposing adding a Detach function. Your thoughts?

@kminehart
Copy link
Author

@kminehart I think you're an idiot. node.RemoveChild already exists.

@golang golang locked and limited conversation to collaborators Aug 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants