This repository has been archived on 2023-03-25. You can view files and clone it, but cannot push or open issues or pull requests.
mightyscape-1.1-deprecated/extensions/fablabchemnitz/svgo-inkscape/node_modules/svgo/plugins/addClassesToSVGElement.js
2020-08-30 12:36:33 +02:00

41 lines
827 B
JavaScript

'use strict';
exports.type = 'full';
exports.active = false;
exports.description = 'adds classnames to an outer <svg> element';
/**
* Add classnames to an outer <svg> element.
*
* @author April Arcus
*/
exports.fn = function(data, params) {
var classNames = params.classNames || [ params.className ];
var svg = data.content[0];
if (svg.isElem('svg')) {
if (svg.hasAttr('class')) {
svg.attr('class').value =
svg.attr('class').value
.split(' ')
.concat(classNames)
.join(' ');
} else {
svg.addAttr({
name: 'class',
value: classNames.join(' '),
prefix: '',
local: 'class'
});
}
}
return data;
};