fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
1 lines • 2.08 kB
Source Map (JSON)
{"version":3,"file":"recursivelyParseGradientsXlink.min.mjs","sources":["../../../src/parser/recursivelyParseGradientsXlink.ts"],"sourcesContent":["const gradientsAttrs = [\n 'gradientTransform',\n 'x1',\n 'x2',\n 'y1',\n 'y2',\n 'gradientUnits',\n 'cx',\n 'cy',\n 'r',\n 'fx',\n 'fy',\n];\nconst xlinkAttr = 'xlink:href';\n\nexport function recursivelyParseGradientsXlink(\n doc: Document,\n gradient: Element,\n) {\n const xLink = gradient.getAttribute(xlinkAttr)?.slice(1) || '',\n referencedGradient = doc.getElementById(xLink);\n if (referencedGradient && referencedGradient.getAttribute(xlinkAttr)) {\n recursivelyParseGradientsXlink(doc, referencedGradient as Element);\n }\n if (referencedGradient) {\n gradientsAttrs.forEach((attr) => {\n const value = referencedGradient.getAttribute(attr);\n if (!gradient.hasAttribute(attr) && value) {\n gradient.setAttribute(attr, value);\n }\n });\n if (!gradient.children.length) {\n const referenceClone = referencedGradient.cloneNode(true);\n while (referenceClone.firstChild) {\n gradient.appendChild(referenceClone.firstChild);\n }\n }\n }\n gradient.removeAttribute(xlinkAttr);\n}\n"],"names":["gradientsAttrs","xlinkAttr","recursivelyParseGradientsXlink","doc","gradient","_gradient$getAttribut","xLink","getAttribute","slice","referencedGradient","getElementById","forEach","attr","value","hasAttribute","setAttribute","children","length","referenceClone","cloneNode","firstChild","appendChild","removeAttribute"],"mappings":"AAAA,MAAMA,EAAiB,CACrB,oBACA,KACA,KACA,KACA,KACA,gBACA,KACA,KACA,IACA,KACA,MAEIC,EAAY,aAEX,SAASC,EACdC,EACAC,GACA,IAAAC,EACA,MAAMC,GAAwCD,QAAhCA,EAAAD,EAASG,aAAaN,cAAUI,SAAhCA,EAAkCG,MAAM,KAAM,GAC1DC,EAAqBN,EAAIO,eAAeJ,GAI1C,GAHIG,GAAsBA,EAAmBF,aAAaN,IACxDC,EAA+BC,EAAKM,GAElCA,IACFT,EAAeW,SAASC,IACtB,MAAMC,EAAQJ,EAAmBF,aAAaK,IACzCR,EAASU,aAAaF,IAASC,GAClCT,EAASW,aAAaH,EAAMC,EAC9B,KAEGT,EAASY,SAASC,QAAQ,CAC7B,MAAMC,EAAiBT,EAAmBU,WAAU,GACpD,KAAOD,EAAeE,YACpBhB,EAASiB,YAAYH,EAAeE,WAExC,CAEFhB,EAASkB,gBAAgBrB,EAC3B"}