I have a foreignObject in an SVG element. All other elements show, but the foreignObject is invisible along with its content. Tested in Chrome, Firefox and Edge, all with the same result.
Here is the code:
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" id="v-2" width="100%" height="100%">
<g id="v-3" class="joint-viewport" transform="matrix(1,0,0,1,-1597.0002028000001,95.99995439999998)">
...
<g id="j_29" model-id="e8dbd7a4-5d3d-44e5-85a0-09413112a39b" class="joint-theme-default joint-cell joint-type-html joint-type-html-element joint-element" data-type="html.Element" fill="#ffffff" stroke="none" transform="translate(1898.0001898,268.0000346)">
<g class="rotatable" id="v-206">
<rect class="body" id="v-207" stroke="none" fill-opacity="0" fill="#ffffff" width="100" height="60"></rect>
<text class="label" id="v-208" font-size="14" y="0.8em" display="none" xml:space="preserve" fill="#000000" text-anchor="middle" font-family="Arial, helvetica, sans-serif" transform="matrix(1,0,0,1,125,20)">
<tspan id="v-209" class="v-line v-empty-line" dy="0em" x="0" style="fill-opacity: 0; stroke-opacity: 0;">-</tspan>
</text>
<foreignObject requiredExtensions="http://www.w3.org/1999/xhtml" width="100%" height="100">
<body xmlns="http://www.w3.org/1999/xhtml">
<input xmlns="http://www.w3.org/1999/xhtml" type="text" value="I'm HTML input">
</body>
</foreignObject>
</g>
</g>
</g>
<defs id="v-4"></defs>
</svg>
Q: What am I doing wrong?
UPDATE: I noticed a few things:
- adding
xmlns="http://www.w3.org/1999/xhtml"
to the input makes it show on Edge. On other browsers, it is still invisible. - On Chrome if I edit the outer
<g>
element by selecting "Edit as HTML", but then make no changes and get out of the editing mode, the input shows up. - adding
requiredExtensions="http://www.w3.org/1999/xhtml"
to theforeignObject
tag and/or the body tag makes no difference.
I must be missing something...