My code adds polylines to a SVG, but these are not rendered.
But if I open the inspector (F12 on Chrome), find them in source, right click on them, edit as HTML, add a space and press enter, they get rendered!
What am I missing here?
function drawLine(x1, y1, x2, y2) {
var line = document.createElement("polyline");
line.style.cssText = "fill:none;stroke:black;stroke-width:2";
var linePoints = `${x1},${y1} ${x2},${y2}`;
line.setAttribute('points', linePoints);
window.linesContainer.appendChild(line);
}
Edit1:
Something interesting is that initially the polyline seems to have 0pxw and 0pxh
While after modifying it, it gets a size: