diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/svgo/plugins/removeElementsByAttr.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/svgo/plugins/removeElementsByAttr.js')
| -rw-r--r-- | node_modules/svgo/plugins/removeElementsByAttr.js | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/node_modules/svgo/plugins/removeElementsByAttr.js b/node_modules/svgo/plugins/removeElementsByAttr.js deleted file mode 100644 index 9c9915f0..00000000 --- a/node_modules/svgo/plugins/removeElementsByAttr.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -const { detachNodeFromParent } = require('../lib/xast.js'); - -exports.name = 'removeElementsByAttr'; -exports.description = - 'removes arbitrary elements by ID or className (disabled by default)'; - -/** - * Remove arbitrary SVG elements by ID or className. - * - * @example id - * > single: remove element with ID of `elementID` - * --- - * removeElementsByAttr: - * id: 'elementID' - * - * > list: remove multiple elements by ID - * --- - * removeElementsByAttr: - * id: - * - 'elementID' - * - 'anotherID' - * - * @example class - * > single: remove all elements with class of `elementClass` - * --- - * removeElementsByAttr: - * class: 'elementClass' - * - * > list: remove all elements with class of `elementClass` or `anotherClass` - * --- - * removeElementsByAttr: - * class: - * - 'elementClass' - * - 'anotherClass' - * - * @author Eli Dupuis (@elidupuis) - * - * @type {import('./plugins-types').Plugin<'removeElementsByAttr'>} - */ -exports.fn = (root, params) => { - const ids = - params.id == null ? [] : Array.isArray(params.id) ? params.id : [params.id]; - const classes = - params.class == null - ? [] - : Array.isArray(params.class) - ? params.class - : [params.class]; - return { - element: { - enter: (node, parentNode) => { - // remove element if it's `id` matches configured `id` params - if (node.attributes.id != null && ids.length !== 0) { - if (ids.includes(node.attributes.id)) { - detachNodeFromParent(node, parentNode); - } - } - // remove element if it's `class` contains any of the configured `class` params - if (node.attributes.class && classes.length !== 0) { - const classList = node.attributes.class.split(' '); - for (const item of classes) { - if (classList.includes(item)) { - detachNodeFromParent(node, parentNode); - break; - } - } - } - }, - }, - }; -}; |
