1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

Prefix ids plugin don't add prefix if prefix is false (#907)

Add to 'prefixIds' the option to pass prefix as false or as a function that returns false
This commit is contained in:
Vitali Zaidman
2018-03-16 19:39:21 +02:00
committed by Lev Solntsev
parent ece039ed8a
commit 0a142f3ca0
2 changed files with 6 additions and 0 deletions

View File

@ -123,6 +123,8 @@ exports.fn = function(node, opts, extra) {
} else {
prefix = opts.prefix;
}
} else if (opts.prefix === false) {
prefix = false;
} else if (extra && extra.path && extra.path.length > 0) {
var filename = path.basename(extra.path);
prefix = filename;
@ -131,6 +133,9 @@ exports.fn = function(node, opts, extra) {
// prefixes a normal value
addPrefix = function(name) {
if(prefix === false){
return escapeIdentifierName(name);
}
return escapeIdentifierName(prefix + opts.delim + name);
};