Skip to content

Instantly share code, notes, and snippets.

@arsonus
Forked from jonathantneal/vendorlessStyle.js
Created February 6, 2018 21:53
Show Gist options
  • Save arsonus/be1a35111cf396e3c8c3a9d47dfa5d86 to your computer and use it in GitHub Desktop.
Save arsonus/be1a35111cf396e3c8c3a9d47dfa5d86 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