Detach attached nodes on appendBeforeSibling callback

html5ever generally makes guarantees about nodes being parentless when
appending, but we've already seen 1 case where appendCallback receives a
connected node.

We're now seeing something in appendBeforeSiblingCallback, but we have a clearer
picture of how this is happening. In this case, it's via custom element
upgrading and the custom element constructor has already placed the node in
the document.

It's worth pointing, html5ever just has an opaque reference to our node. While
it guarantees that it will give us parent-less nodes, it doesn't actually know
anything about our nodes, or our node._parent. The guarantee is only from its
own point of view. There's nothing stopping us from giving a node a default
parent as soon as html5ever asks us to create a new node, in which case, the
node _will_ have a parent.
This commit is contained in:
Karl Seguin
2026-02-18 10:52:51 +08:00
parent 3797272faf
commit 4f6868728d
3 changed files with 41 additions and 2 deletions

View File

@@ -1417,7 +1417,7 @@ pub const Transfer = struct {
header_len = buf_len - 1;
}
const header = buffer[0 .. header_len];
const header = buffer[0..header_len];
// We need to parse the first line headers for each request b/c curl's
// CURLINFO_RESPONSE_CODE returns the status code of the final request.