Skip to content

Inserting elements into SVG doesn't work, wrong NamespaceURI #1088

@ecraven

Description

@ecraven

Bug Report

If you insert any element (via @patch for example) anywhere inside an svg tag, it shows up in the DOM inspector, but it isn't rendered, because the namespaceURI of the element is incorrect ("http://www.w3.org/1999/xhtml"
instead of "http://www.w3.org/2000/svg").

My guess is that datastar always uses document.createElement, but it would have to use document.createElementNS for anything that goes inside SVG.

Is there anything I can do locally to fix this, or would I have to wait for a patch in datastar proper?

Here is a reproduction of it, after 2 seconds, the rectangle is patched and disappears, because the namespace is incorrect. https://codepen.io/cpuser543/pen/jEWRgxv. After the rectangle disappears, go to the inspector, select the rectangle, and look at its namespaceURI

Thank you for a great library!

Datastar Version

v1.0.0-RC.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions