svgdotjs / svg.js

The lightweight library for manipulating and animating SVG
https://svgjs.dev
Other
10.95k stars 1.07k forks source link

Foreign object won't render in Firefox #1318

Closed DesantBucie closed 2 weeks ago

DesantBucie commented 2 weeks ago

Bug report

For support questions, please use stackoverflow with the tag svg.js or head to our chat over at gitter.

Fiddle

https://jsfiddle.net/qau8cs9g/12/

Explanation

Fuzzyma commented 2 weeks ago

svg.js by default creates elements in the svg namespace. Browser dont render divs in svg namespace. In order to create an element in html namespace, you can pass true to the SVG function:

 canvas.foreignObject(100, 100).add(SVG(`<div contenteditable="true" style="color:black;">Text</div>`, true))

Here is your fixed example: https://jsfiddle.net/jd0x6mos/

DesantBucie commented 2 weeks ago

Thanks a lot.