can-dom-data
Associate key/value pair data with a DOM node in a memory-safe way.
Use
import domData from "can-dom-data";
const element = document.createElement("p");
document.body.appendChild(element);
domData.set(element, "metadata", {
hello: "world"
});
let metadata = domData.get(element, "metadata");
// metadata is {hello: "world"}
document.body.removeChild(element);
metadata = domData.get(element, "metadata");
// metadata === undefined because the element was removed from the DOM