Skip to content

SVG elements not created using createElementNS #68

Open
@ScraM-Team

Description

@ScraM-Team

DomBuilder.java:51 always creates elements using createElement. This works for HTML elements, but for SVG elements it causes the browser to not render the SVG. Using svg elements in a template looks OK in the browser inspect pane, but the SVG is not shown.

Instead, the SVG elements need to get created using createElementNS with the SVG namespace URI. One reference: https://stackoverflow.com/questions/3492322/javascript-createelementns-and-svg

A quick but hacky fix is to check for specific SVG tag names in DomBuilder.open(). Unfortunately there are a couple of overlaps between HTML and SVG (like 'title'), so this isn't a complete solution.

It seems a possible better fix is to change parsing to flag DOMElements as SVG. Once the 'svg' parent is seen, all children can automatically be SVG. Then an overloaded open() could call createElementNS for the SVG-flagged DOMElements.

Alternatively, instead of a flag a DOMElement subtype called SVGElement could be created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions