mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Update cleanupIDs.js
added "prefix" parameter to solve problem of combining multiple svg into one svg or html file
This commit is contained in:
@ -6,7 +6,8 @@ exports.active = true;
|
|||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
remove: true,
|
remove: true,
|
||||||
minify: true
|
minify: true,
|
||||||
|
prefix: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
var referencesProps = require('./_collections').referencesProps,
|
var referencesProps = require('./_collections').referencesProps,
|
||||||
@ -123,7 +124,7 @@ exports.fn = function(data, params) {
|
|||||||
// replace referenced IDs with the minified ones
|
// replace referenced IDs with the minified ones
|
||||||
if (params.minify) {
|
if (params.minify) {
|
||||||
|
|
||||||
currentIDstring = getIDstring(currentID = generateID(currentID));
|
currentIDstring = getIDstring(currentID = generateID(currentID), params);
|
||||||
IDs[k].attr('id').value = currentIDstring;
|
IDs[k].attr('id').value = currentIDstring;
|
||||||
|
|
||||||
referencesIDs[k].forEach(function(attr) {
|
referencesIDs[k].forEach(function(attr) {
|
||||||
@ -190,9 +191,9 @@ function generateID(currentID) {
|
|||||||
* @param {Array} arr input ID array
|
* @param {Array} arr input ID array
|
||||||
* @return {String} output ID string
|
* @return {String} output ID string
|
||||||
*/
|
*/
|
||||||
function getIDstring(arr) {
|
function getIDstring(arr, params) {
|
||||||
|
|
||||||
var str = '';
|
var str = params.prefix;
|
||||||
|
|
||||||
arr.forEach(function(i) {
|
arr.forEach(function(i) {
|
||||||
str += generateIDchars[i];
|
str += generateIDchars[i];
|
||||||
|
Reference in New Issue
Block a user