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

Rename plugin to removeElementsByAttr

This commit is contained in:
Eli Dupuis
2016-07-16 11:16:38 -07:00
parent f4b455a65d
commit 7fd48e9d20
4 changed files with 12 additions and 11 deletions

View File

@ -0,0 +1,54 @@
'use strict';
exports.type = 'perItem';
exports.active = false;
exports.description = 'removes arbitrary elements by ID (disabled by default)';
exports.params = {
id: [],
class: []
};
/**
* Remove SVG elements by ID.
*
* @param id
* examples:
*
* > single: remove element with ID of `elementID`
* ---
* removeElementsByAttr:
* id: 'elementID'
*
* > list: remove multiple elements by ID
* ---
* removeElementsByAttr:
* id:
* - 'elementID'
* - 'anotherID'
*
* @param {Object} item current iteration item
* @param {Object} params plugin params
* @return {Boolean} if false, item will be filtered out
*
* @author Eli Dupuis
*/
exports.fn = function(item, params) {
var elemId;
// wrap into an array if params is not
if (!Array.isArray(params.id)) {
params.id = [params.id];
}
if (!item.isElem()) {
return;
}
elemId = item.attr('id');
if (elemId) {
return params.id.indexOf(elemId.value) === -1;
}
};