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:
committed by
Lev Solntsev
parent
ece039ed8a
commit
0a142f3ca0
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ bin/svgo-profiling
|
|||||||
*.sublime-*
|
*.sublime-*
|
||||||
*.log
|
*.log
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.idea
|
||||||
|
@@ -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);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user