Created
February 10, 2016 15:58
-
-
Save thurt/c654dd88e3981f410d50 to your computer and use it in GitHub Desktop.
Simple Data Warehouse
This file contains 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
var Data = function() { | |
var warehouse = {}; | |
var count = 1; | |
return { | |
reset: function() { | |
count = 1; | |
warehouse = {}; | |
}, | |
set: function (dom, data) { | |
if (!dom.__data) { | |
dom.__data = "hello" + count++; | |
} | |
warehouse[dom.__data] = data; | |
}, | |
get: function(dom) { | |
return warehouse[dom.__data]; | |
} | |
}; | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alternative: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Using_data_attributes