Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function(){
- var collected = {}, storage = {};
- var get = function(uid){
- return (storage[uid] || (storage[uid] = {}));
- };
- var purge = function(){
- Hash.each(collected, clean);
- if (Browser.ie) Array.from(document.getElementsByTagName('object')).each(clean);
- if (window.CollectGarbage) CollectGarbage();
- collected = storage = null;
- };
- [Element, Window, Document].invoke('implement', {
- retrieve: function(property, dflt){
- var storage = get(this.uid), prop = storage[property];
- if (dflt != undefined && prop == undefined) prop = storage[property] = dflt;
- return prop != null ? prop : null;
- },
- store: function(property, value){
- var storage = get(this.uid);
- storage[property] = value;
- return this;
- },
- eliminate: function(property){
- var storage = get(this.uid);
- delete storage[property];
- return this;
- }
- });
- window.addListener('unload', purge);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement