mirror of
https://github.com/svg/svgo.git
synced 2025-12-05 09:22:05 +03:00
go!
This commit is contained in:
48
plugins/removeSVGAttrs.js
Normal file
48
plugins/removeSVGAttrs.js
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Remove some useless svg element attributes.
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/struct.html#SVGElement
|
||||
*
|
||||
* @param {Object} item current iteration item
|
||||
* @param {Object} params plugin params
|
||||
* @return {Boolean} if false, item will be filtered out
|
||||
*
|
||||
* @author Kir Belevich
|
||||
*/
|
||||
exports.removeSVGAttrs = function(item, params) {
|
||||
|
||||
if (item.isElem('svg') && item.hasAttr()) {
|
||||
|
||||
/**
|
||||
* Remove id attribute.
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/struct.html#IDAttribute
|
||||
*
|
||||
* @example
|
||||
* <svg id="svg49">
|
||||
*/
|
||||
if (params.id) item.removeAttr('id');
|
||||
|
||||
/**
|
||||
* Remove version attribute.
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/struct.html#SVGElementVersionAttribute
|
||||
*
|
||||
* @example
|
||||
* <svg version="1.1">
|
||||
*/
|
||||
if (params.version) item.removeAttr('version');
|
||||
|
||||
/**
|
||||
* Remove xnl:space attribute.
|
||||
*
|
||||
* @see http://www.w3.org/TR/SVG/struct.html#XMLSpaceAttribute
|
||||
*
|
||||
* @example
|
||||
* <svg xml:space="preserve">
|
||||
*/
|
||||
if (params.xmlspace) item.removeAttr('xml:space');
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user