You do not need the seg polyfill path (pathSeg.js).
With polyfill path data, you can edit the path data as a shared array object.
Use the polyfill path data to work with the new API. Recommended.
var path = document.querySelector('path'); //your <path> element //Be sure you have added the pathdata polyfill to your page before use getPathData var pathdata = path.getPathData(); console.log(pathdata); /* you will get an Array object contains all path data details like this: [ { "type": "M", "values": [ 50, 50 ] }, { "type": "L", "values": [ 200, 200 ] } ] */ //replacement for createSVGPathSegMovetoRel and appendItem pathdata.push({type:'m', values:[200,100]}); path.setPathData(pathdata); //replacement for createSVGPathSegMovetoAbs and appendItem pathdata.push({type:'M', values:[300,120]}); path.setPathData(pathdata); //replacement for createSVGPathSegLinetoAbs and appendItem pathdata.push({type:'L', values:[400,120]}); path.setPathData(pathdata); console.log(path.getAttribute('d')); //create a new path data array var pathdata = [ { "type": "M", "values": [ 50, 50 ] }, { "type": "L", "values": [ 200, 200 ] } ]; path.setPathData(pathdata); console.log(path.getAttribute('d'));
source share