Last active
April 4, 2018 20:26
-
-
Save alexzuza/a975915da436e6f3bd788613e8bef281 to your computer and use it in GitHub Desktop.
IDOM data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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