summaryrefslogtreecommitdiff
path: root/node_modules/svgo/plugins/moveGroupAttrsToElems.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:10:59 +0800
committerlittleblack111 <littleblack11111@gmail.com>2026-05-18 23:41:44 +0800
commitfc87c009806dcc98867f6b58efe29b042aa01dee (patch)
tree8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/svgo/plugins/moveGroupAttrsToElems.js
parent3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff)
node: updatemain
Diffstat (limited to 'node_modules/svgo/plugins/moveGroupAttrsToElems.js')
-rw-r--r--node_modules/svgo/plugins/moveGroupAttrsToElems.js65
1 files changed, 0 insertions, 65 deletions
diff --git a/node_modules/svgo/plugins/moveGroupAttrsToElems.js b/node_modules/svgo/plugins/moveGroupAttrsToElems.js
deleted file mode 100644
index 450fb265..00000000
--- a/node_modules/svgo/plugins/moveGroupAttrsToElems.js
+++ /dev/null
@@ -1,65 +0,0 @@
-'use strict';
-
-const { pathElems, referencesProps } = require('./_collections.js');
-const { includesUrlReference } = require('../lib/svgo/tools.js');
-
-exports.name = 'moveGroupAttrsToElems';
-exports.description = 'moves some group attributes to the content elements';
-
-const pathElemsWithGroupsAndText = [...pathElems, 'g', 'text'];
-
-/**
- * Move group attrs to the content elements.
- *
- * @example
- * <g transform="scale(2)">
- * <path transform="rotate(45)" d="M0,0 L10,20"/>
- * <path transform="translate(10, 20)" d="M0,10 L20,30"/>
- * </g>
- * ⬇
- * <g>
- * <path transform="scale(2) rotate(45)" d="M0,0 L10,20"/>
- * <path transform="scale(2) translate(10, 20)" d="M0,10 L20,30"/>
- * </g>
- *
- * @author Kir Belevich
- *
- * @type {import('./plugins-types').Plugin<'moveGroupAttrsToElems'>}
- */
-exports.fn = () => {
- return {
- element: {
- enter: (node) => {
- // move group transform attr to content's pathElems
- if (
- node.name === 'g' &&
- node.children.length !== 0 &&
- node.attributes.transform != null &&
- Object.entries(node.attributes).some(
- ([name, value]) =>
- referencesProps.has(name) && includesUrlReference(value),
- ) === false &&
- node.children.every(
- (child) =>
- child.type === 'element' &&
- pathElemsWithGroupsAndText.includes(child.name) &&
- child.attributes.id == null,
- )
- ) {
- for (const child of node.children) {
- const value = node.attributes.transform;
- if (child.type === 'element') {
- if (child.attributes.transform != null) {
- child.attributes.transform = `${value} ${child.attributes.transform}`;
- } else {
- child.attributes.transform = value;
- }
- }
- }
-
- delete node.attributes.transform;
- }
- },
- },
- };
-};