In my TypeScript 3.1.1 project in VS Code with an Aurelia setup, I am facing a challenge while trying to manipulate an SVG Polyline using TypeScript code. The issue arises when attempting to create a new SVGPoint object. The initial HTML structure is as follows:
<svg class="distance-polyline-svg" width="100%" height="100%" ref="distancePolylineSvg">
<polyline points="100,100 300,100 200,300 500,300" style="stroke: rgba(6, 28, 129, 0.3); stroke-width: 5; fill: transparent" ref="distancePolyline" />
</svg>
The variables distancePolylineSvg and distancePolyline are declared as SVGElement and SVGPolylineElement respectively.
While accessing a point works fine with this.distancePolyline.points.getItem(i), creating a new point for use in methods like this.distancePolyline.points.replaceItem or this.distancePolyline.points.appendItem has proven to be challenging. Attempts at using new SVGPoint() resulted in a bad constructor error. Switching to new DOMPoint() helped, but issues arose when using it in replaceItem due to the expected parameter type being SVGPoint. Casting SVGElement or SVGPolygonElement did not work either. Additionally, neither of these elements have a method called createSVGPoint, and document.rootElement.createSVGPoint was unsuccessful as rootElement was null.
The main question remains - how can I generate a new SVGPoint to pass to the SVGPointList methods?