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

@@ -7,24 +7,25 @@ exports.active = false;
exports.description = 'removes arbitrary elements by ID (disabled by default)';
exports.params = {
ids: []
id: [],
class: []
};
/**
* Remove SVG elements by ID.
*
* @param ids
* @param id
* examples:
*
* > single: remove element with ID of `elementID`
* ---
* removeElements:
* ids: 'elementID'
* removeElementsByAttr:
* id: 'elementID'
*
* > list: remove multiple elements by ID
* ---
* removeElements:
* ids:
* removeElementsByAttr:
* id:
* - 'elementID'
* - 'anotherID'
*
@@ -38,8 +39,8 @@ exports.fn = function(item, params) {
var elemId;
// wrap into an array if params is not
if (!Array.isArray(params.ids)) {
params.ids = [params.ids];
if (!Array.isArray(params.id)) {
params.id = [params.id];
}
if (!item.isElem()) {
@@ -48,6 +49,6 @@ exports.fn = function(item, params) {
elemId = item.attr('id');
if (elemId) {
return params.ids.indexOf(elemId.value) === -1;
return params.id.indexOf(elemId.value) === -1;
}
};

View File

@@ -11,4 +11,4 @@
@@@
{ "ids": "someID" }
{ "id": "someID" }

Before

Width:  |  Height:  |  Size: 649 B

After

Width:  |  Height:  |  Size: 648 B

View File

@@ -9,4 +9,4 @@
@@@
{ "ids": ["someID", "anotherID"] }
{ "id": ["someID", "anotherID"] }

Before

Width:  |  Height:  |  Size: 468 B

After

Width:  |  Height:  |  Size: 467 B

View File

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 670 B