Skip to content

Commit

Permalink
Fixed addClassesToSVGElement and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
GreLI committed Oct 25, 2017
1 parent eceb95c commit b51192c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
17 changes: 1 addition & 16 deletions plugins/addClassesToSVGElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,7 @@ exports.fn = function(data, params) {
svg = data.content[0];

if (svg.isElem('svg')) {
if (svg.hasAttr('class')) {
var classes = svg.attr('class').value.split(' ');
classNames.forEach(function(className){
if (classes.indexOf(className) < 0) {
classes.push(className);
}
});
svg.attr('class').value = classes.join(' ');
} else {
svg.addAttr({
name: 'class',
value: classNames.join(' '),
prefix: '',
local: 'class'
});
}
svg.class.add.apply(svg.class, classNames);
}

return data;
Expand Down
13 changes: 13 additions & 0 deletions test/plugins/addClassesToSVGElement.01.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b51192c

Please sign in to comment.