Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(removeScriptElement): add all known event types #1819

Merged
merged 1 commit into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/svgo/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ const hasScripts = (node) => {

const eventAttrs = [
...attrsGroups.animationEvent,
...attrsGroups.graphicalEvent,
...attrsGroups.documentEvent,
...attrsGroups.documentElementEvent,
...attrsGroups.globalEvent,
...attrsGroups.graphicalEvent,
];

return eventAttrs.some((attr) => node.attributes[attr] != null);
Expand Down
61 changes: 60 additions & 1 deletion plugins/_collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,72 @@ exports.attrsGroups = {
'xlink:title',
],
documentEvent: [
'onunload',
'onabort',
'onerror',
'onresize',
'onscroll',
'onunload',
'onzoom',
],
documentElementEvent: ['oncopy', 'oncut', 'onpaste'],
globalEvent: [
'oncancel',
'oncanplay',
'oncanplaythrough',
'onchange',
'onclick',
'onclose',
'oncuechange',
'ondblclick',
'ondrag',
'ondragend',
'ondragenter',
'ondragleave',
'ondragover',
'ondragstart',
'ondrop',
'ondurationchange',
'onemptied',
'onended',
'onerror',
'onfocus',
'oninput',
'oninvalid',
'onkeydown',
'onkeypress',
'onkeyup',
'onload',
'onloadeddata',
'onloadedmetadata',
'onloadstart',
'onmousedown',
'onmouseenter',
'onmouseleave',
'onmousemove',
'onmouseout',
'onmouseover',
'onmouseup',
'onmousewheel',
'onpause',
'onplay',
'onplaying',
'onprogress',
'onratechange',
'onreset',
'onresize',
'onscroll',
'onseeked',
'onseeking',
'onselect',
'onshow',
'onstalled',
'onsubmit',
'onsuspend',
'ontimeupdate',
'ontoggle',
'onvolumechange',
'onwaiting',
],
filterPrimitive: ['x', 'y', 'width', 'height', 'result'],
transferFunction: [
'type',
Expand Down
4 changes: 3 additions & 1 deletion plugins/removeScriptElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ exports.description = 'removes scripts (disabled by default)';
/** Union of all event attributes. */
const eventAttrs = [
...attrsGroups.animationEvent,
...attrsGroups.graphicalEvent,
...attrsGroups.documentEvent,
...attrsGroups.documentElementEvent,
...attrsGroups.globalEvent,
...attrsGroups.graphicalEvent,
];

/**
Expand Down
Loading