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

Deprecate removeEmptyAttrs #39

Merged
merged 2 commits into from
Oct 6, 2024
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: 4 additions & 0 deletions plugins/cleanupStyleAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ export const fn = (root, params, info) => {
return;
}

if (node.attributes['style'] === '') {
delete node.attributes.style;
}

const origProperties = getStyleDeclarations(node);
if (!origProperties) {
return;
Expand Down
2 changes: 0 additions & 2 deletions plugins/preset-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as removeComments from './removeComments.js';
import * as removeDesc from './removeDesc.js';
import * as removeDoctype from './removeDoctype.js';
import * as removeEditorsNSData from './removeEditorsNSData.js';
import * as removeEmptyAttrs from './removeEmptyAttrs.js';
import * as removeEmptyContainers from './removeEmptyContainers.js';
import * as removeEmptyText from './removeEmptyText.js';
import * as removeHiddenElems from './removeHiddenElems.js';
Expand Down Expand Up @@ -58,7 +57,6 @@ const presetDefault = createPreset({
convertShapeToPath,
combinePaths,
minifyPathData,
removeEmptyAttrs,
removeEmptyContainers,
removeUnusedNS,
],
Expand Down
2 changes: 0 additions & 2 deletions plugins/preset-next.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as removeComments from './removeComments.js';
import * as removeDesc from './removeDesc.js';
import * as removeDoctype from './removeDoctype.js';
import * as removeEditorsNSData from './removeEditorsNSData.js';
import * as removeEmptyAttrs from './removeEmptyAttrs.js';
import * as removeEmptyContainers from './removeEmptyContainers.js';
import * as removeEmptyText from './removeEmptyText.js';
import * as removeHiddenElems from './removeHiddenElems.js';
Expand Down Expand Up @@ -58,7 +57,6 @@ const presetNext = createPreset({
convertShapeToPath,
combinePaths,
minifyPathData,
removeEmptyAttrs,
removeEmptyContainers,
removeUnusedNS,
],
Expand Down
9 changes: 9 additions & 0 deletions plugins/removeEmptyAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { attrsGroups } from './_collections.js';
export const name = 'removeEmptyAttrs';
export const description = 'removes empty attributes';

let deprecationWarning = true;

/**
* Remove attributes with empty values.
*
Expand All @@ -11,6 +13,13 @@ export const description = 'removes empty attributes';
* @type {import('./plugins-types.js').Plugin<'removeEmptyAttrs'>}
*/
export const fn = () => {
if (deprecationWarning) {
console.warn(
'The removeEmptyAttrs plugin is deprecated and will be removed in a future release.',
);
deprecationWarning = false;
}

return {
element: {
enter: (node) => {
Expand Down
2 changes: 1 addition & 1 deletion plugins/removeUselessDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let deprecationWarning = true;
export const fn = () => {
if (deprecationWarning) {
console.warn(
'The moveGroupAttrsToElems plugin is deprecated and will be removed in a future release.',
'The removeUselessDefs plugin is deprecated and will be removed in a future release.',
);
deprecationWarning = false;
}
Expand Down