mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Replace attributes iterators with for/of (#1431)
These iterators allows to directly manipulate passed value which does not let us to get rid from legacy "attrs" field. Object.entries makes it easier to get an access to both attribute name and value.
This commit is contained in:
@ -49,13 +49,13 @@ exports.fn = function (item, params) {
|
||||
.join(' ');
|
||||
}
|
||||
|
||||
item.eachAttr(function (attr) {
|
||||
for (const [name, value] of Object.entries(item.attributes)) {
|
||||
// The `version` attribute is a text string and cannot be rounded
|
||||
if (attr.name === 'version') {
|
||||
return;
|
||||
if (name === 'version') {
|
||||
continue;
|
||||
}
|
||||
|
||||
var match = attr.value.match(regNumericValues);
|
||||
var match = value.match(regNumericValues);
|
||||
|
||||
// if attribute value matches regNumericValues
|
||||
if (match) {
|
||||
@ -85,8 +85,8 @@ exports.fn = function (item, params) {
|
||||
units = '';
|
||||
}
|
||||
|
||||
attr.value = num + units;
|
||||
item.attributes[name] = num + units;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user