If the system had been designed to create instances of some `Contact` type, then you could've benefitted from using a WeakMap[0] here, where each `contact` object's identity is used as the key which is mapped to the DOM node. This would provide cache clearing for free once the `contact` object's references were unreachable It could also be done in reverse, using the node as the key and the `contact` object at the value. Once the `node` was removed from the DOM and references were unreachable, any future GC operation could safely remove the entry from the cache.

[0] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/WeakMap