Skip to content

@cpojer /Element.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
// Upgrade from MooTools Core 1.2 to MooTools Core 1.3
//
// Brings compatibility for Element.set and Element.get with multipe arguments.
// Use at your own risk; if cou can - fix your code and do not use this script.
// -- @cpojer
(function(){
Element.implement({
// from 1.2
set: function(prop, value){
switch (typeOf(prop)){
case 'object':
for (var p in prop) this.set(p, prop[p]);
break;
case 'string':
var property = Element.Properties[prop];
(property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);
}
return this;
},
get: function(prop){
var property = Element.Properties[prop];
return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);
}
});
var props = Element.Properties;
var wrap = function(prop){
if (!props[prop]) return wrap;
var getter = props[prop].get;
props[prop].get = function(options){
if (options) this.set(prop, options);
return getter.call(this);
};
return wrap;
};
wrap('tween')('morph')('load')('send');
})(Element.Properties);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.