Skip to content

Instantly share code, notes, and snippets.

@jb55
Created February 25, 2014 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jb55/9199923 to your computer and use it in GitHub Desktop.
Save jb55/9199923 to your computer and use it in GitHub Desktop.
var uid = require('uid');
var data = require('data');
function hash(el) {
var d = data(el);
var hash = d.get('mylib:uid');
if (hash) return hash;
var id = uid();
d.set('mylib:uid', id);
return id;
}
var lookup = {};
var el = document.querySelector('.some-el');
lookup[hash(el)] = 'some element data';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment