Closed BrinaryG closed 6 years ago
Hi @BrinaryG babel plugin does not mark children as SVG elements for now. It only marks SVG and passes isSVG
down in the patch routine. But I think your idea is good and maybe it would be better to list all SVG elements and mark them as svg elements. This way we could simplify the logic too!
I am having trouble adding elements to an svg after it has rendered without using createVNode when using the code below the element is not flagged as a SVGElement. The transpiled code recieves a VNodeFlag of HtmlElement.
<g name="minimap"> <line x1={HORIZ_PADDING} y1={VERT_PADDING} x2={mapWidth} y2={VERT_PADDING} strokeWidth={LINE_WIDTH} stroke="#ccc" />, <line x1={HORIZ_PADDING + xOff} y1={VERT_PADDING} x2={xOff + thumbWidth} y2={VERT_PADDING} strokeWidth={LINE_WIDTH} stroke="#f00" /> </g>
However when using createVNode and setting the VNode flag manually the element is rendered correctly
return createVNode( VNodeFlags.SvgElement, 'g', null, [ <line x1={HORIZ_PADDING} y1={VERT_PADDING} x2={mapWidth} y2={VERT_PADDING} strokeWidth={LINE_WIDTH} stroke="#ccc" />, <line x1={HORIZ_PADDING + xOff} y1={VERT_PADDING} x2={xOff + thumbWidth} y2={VERT_PADDING} strokeWidth={LINE_WIDTH} stroke="#f00" /> ], ChildFlags.HasNonKeyedChildren, { name: 'minimap' } );
Thanks
Brian