Skip to content

Commit

Permalink
Merge pull request #530 from ricardobeat/master
Browse files Browse the repository at this point in the history
add removeXMLNS plugin
  • Loading branch information
GreLI committed Aug 25, 2016
2 parents 517449f + 768107b commit 0a9870a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .svgo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ plugins:
- removeXMLProcInst
- removeComments
- removeMetadata
- removeXMLNS
- removeEditorsNSData
- cleanupAttrs
- minifyStyles
Expand Down
28 changes: 28 additions & 0 deletions plugins/removeXMLNS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

exports.type = 'perItem';

exports.active = false;

exports.description = 'removes xmlns attribute (for inline svg, disabled by default)';

/**
* Remove the xmlns attribute when present.
*
* @example
* <svg viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg">
* ↓
* <svg viewBox="0 0 100 50">
*
* @param {Object} item current iteration item
* @return {Boolean} if true, xmlns will be filtered out
*
* @author Ricardo Tomasi
*/
exports.fn = function(item) {

if (item.isElem('svg') && item.hasAttr('xmlns')) {
item.removeAttr('xmlns');
}

};

0 comments on commit 0a9870a

Please sign in to comment.