Repository navigation
Conversation
|
The test workflow is waiting for approval to run. Could a maintainer approve it when convenient? The local Go 1.27.4 race/coverage suite, vet and build passed; the upstream Go/OS matrix is still unverified. |
|
Hello, Thanks for the PR, I'm double-checking if there are other places that would need the same fix and I believe Thanks, |
|
Thanks, Martin. I've updated both methods in 2c74c08. The regression tests exercise all three wrapping methods with mixed, non-element-only and empty selections. They also cover wrapping the document element with GitHub is waiting for workflow approval on this commit. |
|
Thanks for the update. On closer look I need to think about this a little more, I only want to fix the case that may panic, not change the behaviour of any of those methods. It's probably ok to wrap a non-element node with the provided html, I think it's only an issue when its parent (which is used as context to parse the provided html) is not an element. |
|
Thanks, Martin. You were right about wrapping text and comments. I checked the DOM on master: calling
The mixed-content assertion now passes on both master and this branch. The full race suite passed on the revised branch and with the patch applied to current master. |
WrapHtmlparses the wrapper in the selected node’s parent. When wrapping the document element, the parent is a document node. Use the existing detached-node fallback for that case. Text and comment nodes with an element parent continue to be wrapped separately, as on master.WrapInnerHtmluses the selected node itself as the fragment context. Only element nodes can provide that context. It skips non-element nodes in a mixed selection and still wraps the contents of the selected elements.The regression tests check the serialized DOM for mixed text, comments and elements, and that wrapping the document element keeps the original element inside the wrapper.
WrapAllHtmlhas no changes in this diff. The first-node context used by that method is covered by #620.On macOS arm64 with Go 1.27.4, the mixed-content
WrapHtmlassertion passed on master and failed on the previous PR head (2c74c08). The revised branch passedgo test ./... -race -cover -shuffle=on -count=1,go vet ./..., andgo build ./.... The full race suite also passed with the patch applied to master at cc872d8.The four fork CI jobs passed the full race suite, vet and build on Linux and Windows with both Go 1.26.x and 1.27.x. These jobs checked out the PR commit
36faee23.Codex assisted with the implementation, verification, and this description.