Last active
December 21, 2022 01:15
-
-
Save aquaductape/73a641649b8004e107a067648ac2c6e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function namespaceSVGId(svg, namespace) { | |
svg = svg.replace(/id="(.*?)"/g, (_, p1) => { | |
return `id="${namespace}-${p1}"`; | |
}); | |
svg = svg.replace(/xlink:href="#(.*?)"/g, (_, p1) => { | |
return `xlink:href="#${namespace}-${p1}"`; | |
}); | |
svg = svg.replace(/mask="url\(#(.*?)\)"/g, (_, p1) => { | |
return `mask="url(#${namespace}-${p1})"`; | |
}); | |
svg = svg.replace(/fill="url\(#(.*?)\)"/g, (_, p1) => { | |
return `fill="url(#${namespace}-${p1})"`; | |
}); | |
svg = svg.replace(/filter="url\(#(.*?)\)"/g, (_, p1) => { | |
return `filter="url(#${namespace}-${p1})"`; | |
}); | |
return svg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment