1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-29 20:21:14 +03:00

Fix empty <svg /> in cleanupIDs plugin

This commit is contained in:
Bogdan Chadkin
2021-02-21 14:50:55 +03:00
parent 727646e6a7
commit 9b97e06ef6
2 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,7 @@ exports.fn = function(data, params) {
}
// Don't remove IDs if the whole SVG consists only of defs.
if (item.isElem('svg')) {
if (item.isElem('svg') && item.content) {
var hasDefsOnly = true;
for (var j = 0; j < item.content.length; j++) {

View File

@ -57,4 +57,8 @@ describe('svgo', () => {
expect(result.error).to.match(/Error in parsing SVG/);
expect(result.path).to.equal('input.svg');
});
it('should handle empty svg tag', async () => {
const result = optimize('<svg />', { input: 'file', path: 'input.svg' });
expect(result.data).to.equal('<svg/>');
});
});