mirror of
https://github.com/svg/svgo.git
synced 2025-07-29 20:21:14 +03:00
Access attributes directly (#1433)
Got rid from `.attrs`, `.attr()` and `.addAttr()` usages
This commit is contained in:
@ -39,9 +39,9 @@ exports.fn = function (item, params) {
|
||||
if (item.type === 'element') {
|
||||
var floatPrecision = params.floatPrecision;
|
||||
|
||||
if (item.hasAttr('viewBox')) {
|
||||
var nums = item.attr('viewBox').value.split(/\s,?\s*|,\s*/g);
|
||||
item.attr('viewBox').value = nums
|
||||
if (item.attributes.viewBox != null) {
|
||||
var nums = item.attributes.viewBox.split(/\s,?\s*|,\s*/g);
|
||||
item.attributes.viewBox = nums
|
||||
.map(function (value) {
|
||||
var num = +value;
|
||||
return isNaN(num) ? value : +num.toFixed(floatPrecision);
|
||||
|
Reference in New Issue
Block a user