Skip to content

Conversation

@TjeuKayim
Copy link

@TjeuKayim TjeuKayim commented Nov 5, 2025

↪️ Pull Request

This pull-request fixes issue #10172 where an <svg> tag makes the next siblings disappear.

💻 Examples

Let's say you have the following HTML:

<svg><circle/></svg>
<p>aaa</p>
<p>bbb</p>

You would expect parcel build to keep the <p> elements, but it actually removed those elements. What adds to the confusion is that the bug did not happen with parcel serve and parcel build --no-optimize. So, it will be nice to have this bug fixed.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Included links to related issues/PRs

This fixes issue parcel-bundler#10172 where an <svg> tag
makes the next siblings disappear.
// Reattach in original position.
node.parent.set(parent);
node.previous_sibling.set(previous_sibling);
node.next_sibling.set(next_sibling);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternative approach:

            // Remember the original position
            let stub = arena.alloc(Node::new(NodeData::Document, 0));
            node.insert_after(stub);

            // Synthesize a fake document node to act as the root of the SVG.
            let document = arena.alloc(Node::new(NodeData::Document, 0));
            document.append(node);

            _ = options.minify_svg.into_jobs(OxvgKind::Html).run(
              &&*document,
              &oxvg_ast::visitor::Info::<crate::oxvg::Element>::new(arena),
            );

            // Reattach
            stub.insert_after(node);
            stub.detach();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant