1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-07 15:22:54 +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

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ bin/svgo-profiling
*.sublime-* *.sublime-*
*.log *.log
.DS_Store .DS_Store
.idea

View File

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