Please see my previous messages here and here. The original SVG has xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" for <svg> and xmlns="http://www.w3.org/1999/xhtml" for <div> (in text and in the dom when loaded directly from file, no TW), but doesn’t have them (in the dom) when rendered by TW. That is, the tiddler text has them, but when I inspect the DOM of the rendered tiddler they are not there.
I just tried this:
created a tiddler with the SVG text from the first message (with the xmlns).
the ‘tiddlywiki’ label is not seen in the rendered rectangle
in dev tools, i located the svg node, used ‘edit as html’, and pasted the original SVG text (with the xmlns). That is, replaced the DOM that TW rendered with the original text.
The label became visible.
So this is nothing to do with styling of browser support but simply the fact that TW mangles the tiddler text when rendering as SVG.
Is there a way for me to create a content type or something like that where TW will just take the text as is and use it as innerHTML of the surrounding div?
Of course I think this is what TW should do with SVG tiddlers to begin with, but don’t want to wait for it. In my view, only if a user uses [img[tiddler]] to include a tiddler should the text be converted to a data blob and optimally there should be a [svg[tiddler]] to include svg elements (with the ability to specify class and dimensions that transcluding doesn’t allow). SVG elements seem to be more aligned with “wiki” (being just text and not binary data), so I wish TW would have better support for them.
I think I found the problem. It’s not from the outer SVG namespace, because as I wrote that namespace is set in the right way, when the element is created using the javascript createElementNS() function.
It seems the foreignObject first div element, which switches back to xmlns="http://www.w3.org/1999/xhtml" isn’t recognised in the right way.
As shown in the GitHub code, TW sets this namespace with the BODY element. So I did test the following code, which contains an additional body element in the foreignObject element, TW switches to the HTML namespace and the SVG works.
So this seems to be the issue / bug. I’ll create a new issue at GitHub.
Javascript may create the element, but in dev tools it is not shown. Here are two screen shots. In the first, the SVG is loaded from a file, no TW. In the second, it is the result of the same text, when rendered by TW. As you can see, all xmlns attributes are missing. As mentioned, if I take the second dom, edit as HTML and paste the original context, then the xmlns attributes remain and the SVG is rendered correctly
Yes, because if you edit the DOM directly with the dev-tools and change the HTML code, the browser dev tools do the rendering.
As I wrote – TW uses JS functions the set the namespace according to the elements eg: SVG, BODY and MATH … As written in the GH issue, there is bug at the moment and there is a pending pull request, which should fix the problem.
The missing attributes are inconvenient, but they are not the problem. There may be a future PR to fix that too but more testing will be needed.
Does this attribute bug happen when you leave the type blank or set it to text/vnd.tiddlywiki, and then transclude the SVG tiddler into another one open in the story river via {{svgTiddler}}?