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:
@ -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++) {
|
||||
|
@ -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/>');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user