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:
@@ -7,24 +7,25 @@ exports.active = false;
|
|||||||
exports.description = 'removes arbitrary elements by ID (disabled by default)';
|
exports.description = 'removes arbitrary elements by ID (disabled by default)';
|
||||||
|
|
||||||
exports.params = {
|
exports.params = {
|
||||||
ids: []
|
id: [],
|
||||||
|
class: []
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove SVG elements by ID.
|
* Remove SVG elements by ID.
|
||||||
*
|
*
|
||||||
* @param ids
|
* @param id
|
||||||
* examples:
|
* examples:
|
||||||
*
|
*
|
||||||
* > single: remove element with ID of `elementID`
|
* > single: remove element with ID of `elementID`
|
||||||
* ---
|
* ---
|
||||||
* removeElements:
|
* removeElementsByAttr:
|
||||||
* ids: 'elementID'
|
* id: 'elementID'
|
||||||
*
|
*
|
||||||
* > list: remove multiple elements by ID
|
* > list: remove multiple elements by ID
|
||||||
* ---
|
* ---
|
||||||
* removeElements:
|
* removeElementsByAttr:
|
||||||
* ids:
|
* id:
|
||||||
* - 'elementID'
|
* - 'elementID'
|
||||||
* - 'anotherID'
|
* - 'anotherID'
|
||||||
*
|
*
|
||||||
@@ -38,8 +39,8 @@ exports.fn = function(item, params) {
|
|||||||
var elemId;
|
var elemId;
|
||||||
|
|
||||||
// wrap into an array if params is not
|
// wrap into an array if params is not
|
||||||
if (!Array.isArray(params.ids)) {
|
if (!Array.isArray(params.id)) {
|
||||||
params.ids = [params.ids];
|
params.id = [params.id];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!item.isElem()) {
|
if (!item.isElem()) {
|
||||||
@@ -48,6 +49,6 @@ exports.fn = function(item, params) {
|
|||||||
|
|
||||||
elemId = item.attr('id');
|
elemId = item.attr('id');
|
||||||
if (elemId) {
|
if (elemId) {
|
||||||
return params.ids.indexOf(elemId.value) === -1;
|
return params.id.indexOf(elemId.value) === -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
@@ -11,4 +11,4 @@
|
|||||||
|
|
||||||
@@@
|
@@@
|
||||||
|
|
||||||
{ "ids": "someID" }
|
{ "id": "someID" }
|
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 648 B |
@@ -9,4 +9,4 @@
|
|||||||
|
|
||||||
@@@
|
@@@
|
||||||
|
|
||||||
{ "ids": ["someID", "anotherID"] }
|
{ "id": ["someID", "anotherID"] }
|
Before Width: | Height: | Size: 468 B After Width: | Height: | Size: 467 B |
Before Width: | Height: | Size: 670 B After Width: | Height: | Size: 670 B |
Reference in New Issue
Block a user