document.createElementNs is "not a function" [closed]

1 day ago 3
ARTICLE AD BOX

I'm getting the following error:
threeDModel.js:85 Uncaught TypeError: document.createElementNs is not a function

The piece of code in question is an exact copy of the same code later on, which functions fine. The code with the error:

function buttonTest(){ let testCircle = document.createElementNs(svgNs, "circle"); testCircle.setAttributeNs(null, "cx", "100"); testCircle.setAttributeNs(null, "cy", "100"); testCircle.setAttributeNs(null, "r", "5"); theSvg.appendChild(testCircle); }

The duplicate line which works further on is a function property within an object:

plotVertice : function(event){ let trueX = event.clientX - xOffset; let trueY = event.clientY - yOffset; if (!dragging){ this.tempEvent = event; this.tempVertices.push(trueX, trueY); let adjuster = document.createElementNS(svgNs, "circle"); adjuster.setAttribute("r", 10); adjuster.setAttribute("cx", trueX); adjuster.setAttribute("cy", trueY); adjuster.setAttribute("draggable", "true"); adjuster.setAttribute("class", "draggable"); // for styling this.tempAdjusters.push(adjuster); theSvg.appendChild(adjuster); this.updateOutline(); } },

Why isn't createElementNs being recognised in the first context? buttonTest() is just a vanilla function, it's not nested in anything else.

Read Entire Article