Skip to content

Instantly share code, notes, and snippets.

@jonathantneal
Created August 19, 2012 07:41
Show Gist options
  • Save jonathantneal/3393376 to your computer and use it in GitHub Desktop.
Save jonathantneal/3393376 to your computer and use it in GitHub Desktop.
vendorlessStyle // allows DOM elements to support vendorless properties
this.CSSStyleDeclaration && function (CSSStyleDeclarationPrototype, defaultStyles, defaultProperty, specialProperty) {
for (defaultProperty in defaultStyles) {
specialProperty = defaultProperty.match(/^(O|Moz|ms|webkit)([A-Z])(.*)$/);
specialProperty && function (defaultProperty, genericProperty) {
Object.defineProperty(CSSStyleDeclarationPrototype, genericProperty, {
get: function () {
return this[defaultProperty];
},
set: function (value) {
return this[defaultProperty] = value;
},
enumerable: true
});
}(defaultProperty, specialProperty[2].toLowerCase() + specialProperty[3]);
}
}(CSSStyleDeclaration.prototype, document.createElement("x").style);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment