@qrac/svgstore
Version:
Combines mulitple svg files into one.
31 lines (21 loc) • 552 B
JavaScript
/**
* Utility to copy specific attributes from one node to another.
*/
;
var ALWAYS_COPY_ATTRS = ['viewBox', 'aria-labelledby', 'role'];
function copyAttributes(a, b, attrs) {
var attrsToCopy = ALWAYS_COPY_ATTRS.concat(attrs || []);
var copiedAttrs = Object.create(null);
attrsToCopy.forEach(function (attr) {
if (!attr || copiedAttrs[attr]) {
return;
}
copiedAttrs[attr] = true;
var bAttr = b.attr(attr);
if (bAttr != null) {
a.attr(attr, b.attr(attr));
}
});
return a;
}
module.exports = copyAttributes;