Thanks!
The stickers are non-vector, but in the application I also include a lot of vector-elements like rect and text, hence the fairly large frame of the SVG. I just omitted them for brevity.
I can rectify the IDs as you suggest, I just haven't gotten past the current issue yet.
Scaling with transform seemed to be the most apt way to preserve the viewBox- and preserveAspectRatio-attributes of the SVG, at least when I was building the original SVG. This was also easier to apply when the SVG is absolutely positioned, because it will stack with other SVGs and a background image, thus keeping them the same size consistently. The application emulates layers in graphical editors a bit in that regard, overlaying colors in the rectangles.
It probably is easy enough to do with the native API, but the LocalForage API is so elegantly written I just fell for it. Also easy to grab all of the relevant data and POST it somewhere.
I tried with having the stickers absolutely positioned in a separate "layer" initially, but had some problems maintaining the bounds within the SVG when dragging them. The problem seems to be that the matrix is applied onDragEnd and so the x,y I get from "this.x" or "this.target.getBoundingClientRect().x" is inaccurate when loaded again. This is why I use "sticker.setAttributeNS(null, "transform", `matrix(1, 0, 0, 1, ${x}, ${y})`);" in the build()-function. I also tried setting the x- and y-attribute, but at no point could I get an accurate value for them when reapplying the position.
It also produces a rather easy to handle SVG-element that I can easily reuse, change the Z-index of, or transport elsewhere.
Does the inaccurate location happen because of the scaling, and would I need to calculate the x and y relative to the SVG itself? I'm a bit confused about what units I am working with and what they are relative to, and how to maintain location when I scale the element(s).