1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-01 18:46:52 +03:00

refactor(cleanupNumbericValues): improve how viewbox is split (#2046)

This commit is contained in:
Seth Falco
2024-07-02 10:07:57 +01:00
committed by GitHub
parent a59f47b98c
commit 9078e8ca08

View File

@ -37,9 +37,8 @@ export const fn = (_root, params) => {
element: { element: {
enter: (node) => { enter: (node) => {
if (node.attributes.viewBox != null) { if (node.attributes.viewBox != null) {
const nums = node.attributes.viewBox.split(/\s,?\s*|,\s*/g); const nums = node.attributes.viewBox.trim().split(/(?:\s,?|,)\s*/g);
node.attributes.viewBox = nums node.attributes.viewBox = nums
.filter((value) => value.length != 0)
.map((value) => { .map((value) => {
const num = Number(value); const num = Number(value);
return Number.isNaN(num) return Number.isNaN(num)