signed up just to say thank you for this snippet.
had almost exactly need to have unique id for nodes.
but all this seems a bit overhead just to set attribute, don’t you think? or there is another simpler way already?
also, got small issue, as i’m using typescript, there was an error with typing in
dom.getAttribute()
because dom should be Node | string type. isn’t it?