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/removeScriptElement.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/svgo/plugins/removeScriptElement.js')
| -rw-r--r-- | node_modules/svgo/plugins/removeScriptElement.js | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/node_modules/svgo/plugins/removeScriptElement.js b/node_modules/svgo/plugins/removeScriptElement.js deleted file mode 100644 index 80fcea3b..00000000 --- a/node_modules/svgo/plugins/removeScriptElement.js +++ /dev/null @@ -1,70 +0,0 @@ -'use strict'; - -const { detachNodeFromParent } = require('../lib/xast.js'); -const { attrsGroups } = require('./_collections.js'); - -exports.name = 'removeScriptElement'; -exports.description = 'removes scripts (disabled by default)'; - -/** Union of all event attributes. */ -const eventAttrs = [ - ...attrsGroups.animationEvent, - ...attrsGroups.documentEvent, - ...attrsGroups.documentElementEvent, - ...attrsGroups.globalEvent, - ...attrsGroups.graphicalEvent, -]; - -/** - * Remove scripts. - * - * https://www.w3.org/TR/SVG11/script.html - * - * @author Patrick Klingemann - * @type {import('./plugins-types').Plugin<'removeScriptElement'>} - */ -exports.fn = () => { - return { - element: { - enter: (node, parentNode) => { - if (node.name === 'script') { - detachNodeFromParent(node, parentNode); - return; - } - - for (const attr of eventAttrs) { - if (node.attributes[attr] != null) { - delete node.attributes[attr]; - } - } - }, - exit: (node, parentNode) => { - if (node.name !== 'a') { - return; - } - - for (const attr of Object.keys(node.attributes)) { - if (attr === 'href' || attr.endsWith(':href')) { - if ( - node.attributes[attr] == null || - !node.attributes[attr].trimStart().startsWith('javascript:') - ) { - continue; - } - - const index = parentNode.children.indexOf(node); - parentNode.children.splice(index, 1, ...node.children); - - // TODO remove legacy parentNode in v4 - for (const child of node.children) { - Object.defineProperty(child, 'parentNode', { - writable: true, - value: parentNode, - }); - } - } - } - }, - }, - }; -}; |
