Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
making cloning element storage in mootools possible
(function() {
var eliminateOrig = Element.prototype.eliminate;
var localStorage = {};
var get = function(uid){
return (localStorage[uid] || (localStorage[uid] = [])); // converted to an array to store keys stored
};
Element.implement({
lstore: function(property, value) {
// use this instead of Element.store
var storage = get(this.uid);
// store the key so we can clone it after
if (!storage[property])
storage.push(property);
return this.store.apply(this, arguments);
},
eliminate: function(property) {
var storage = get(this.uid);
storage.erase(property);
return eliminateOrig.apply(this, arguments);
},
cloneStorage: function(from) {
// new prototype to clone
var other = get(from.uid);
other.each(function(el) {
this.lstore(el, from.retrieve(el));
}, this);
return this;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.