Skip to content

Commit

Permalink
feat(removeUnknownsAndDefaults): remove version attribute from <svg>
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkenny54 committed Nov 17, 2024
1 parent 5327763 commit a36459b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
11 changes: 0 additions & 11 deletions plugins/_collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,6 @@ export const elems = {
'height',
'preserveAspectRatio',
'style',
'version',
'viewBox',
'width',
'x',
Expand All @@ -1764,20 +1763,10 @@ export const elems = {
height: '100%',
preserveAspectRatio: 'xMidYMid meet',
zoomAndPan: 'magnify',
version: '1.1',
baseProfile: 'none',
contentScriptType: 'application/ecmascript',
contentStyleType: 'text/css',
},
deprecated: {
safe: new Set(['version']),
unsafe: new Set([
'baseProfile',
'contentScriptType',
'contentStyleType',
'zoomAndPan',
]),
},
contentGroups: new Set([
'animation',
'descriptive',
Expand Down
7 changes: 5 additions & 2 deletions plugins/removeUnknownsAndDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export const fn = (root, params, info) => {
}
// See if the element or any of its parents are used.
while (true) {
if (element.attributes.id && usedIDs.has(element.attributes.id)) {
if (
element.attributes.id &&
usedIDs.has(element.attributes.id.toString())
) {
return true;
}
const parent = element.parentNode;
Expand Down Expand Up @@ -294,7 +297,7 @@ export const fn = (root, params, info) => {
// (b) not inheritable, and a default value.
const isDefault = isDefaultPropertyValue(
name,
value,
value.toString(),
attributesDefaults,
);
if (inheritableAttrs.has(name)) {
Expand Down
13 changes: 13 additions & 0 deletions test/plugins/removeUnknownsAndDefaults.32.svg.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Remove <svg> version attribute.

===

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" version="1.0">
<rect width="20" height="26" style="fill:blue;fill-opacity:0.5"/>
</svg>

@@@

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30">
<rect width="20" height="26" style="fill:blue;fill-opacity:0.5"/>
</svg>

0 comments on commit a36459b

Please sign in to comment.