Skip to content

Instantly share code, notes, and snippets.

@alexzuza
Last active April 4, 2018 20:26
Show Gist options
  • Save alexzuza/a975915da436e6f3bd788613e8bef281 to your computer and use it in GitHub Desktop.
Save alexzuza/a975915da436e6f3bd788613e8bef281 to your computer and use it in GitHub Desktop.
IDOM data
const NODE_DATA_KEY = '__ID_Data__';
class NodeData {
// key
// attrs
constructor(name) {
this.name = name;
this.text = null;
}
}
function getData(node) {
if (!node[NODE_DATA_KEY]) {
node[NODE_DATA_KEY] = new NodeData(node.nodeName.toLowerCase());
}
return node[NODE_DATA_KEY];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment