Closed dmnsgn closed 2 years ago
That's a good catch, thanks @dmnsgn! I guess a good fix would be to update numericAttribs()
to also check each of the selected attrib values if there're numeric to begin with and only if so format them with ff()
. Otherwise the function would/should just leave them as is...
export const numericAttribs = (attribs: any, ...ids: string[]) => {
let v: any;
for (let id of ids) {
typeof (v = attribs[id]) === "number" && (attribs[id] = ff(v));
}
return attribs;
};
numericAttribs({ width: 1.123456, height: "12px"}, "width","height")
// { width: '1.12', height: '12px' }
Started a PR with your suggested change here if you need it: https://github.com/thi-ng/umbrella/pull/313
Thanks again, @dmnsgn - your fix is already released, plus I've just added some more changes/updates to the related logic (still unreleased): bf06b655393f1d08f8bab6d451ca8171ee71796f
svg spec
width
andheight
attribute are of data type \<length> so, if I get this right, the recent use ofnumericAttribs()
(https://github.com/thi-ng/umbrella/commit/d6cb9929d274c83e89670e9140bba1cb172a0deb) seem to have enforced a numerical value to be passed as attribute? That means we're gettingTypeError: x.toFixed is not a function
fromff()
when trying to pass a value with unit identifier: