Skip to content

Instantly share code, notes, and snippets.

@nuxodin
Created July 12, 2018 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxodin/1a853c475453622e3c0939c7e52afa60 to your computer and use it in GitHub Desktop.
Save nuxodin/1a853c475453622e3c0939c7e52afa60 to your computer and use it in GitHub Desktop.
!function() {
// style
var styleObj = d.documentElement.style;
var vendors = {'moz':1,'webkit':1,'ms':1,'o':1};
c1.dom.css = function(el, style, value) {
if (value === undefined) {
if (typeof style === 'string') {
// getter
if (styleObj[style] !== undefined) return getComputedStyle(el).getPropertyValue(style);
return getComputedStyle(el).getPropertyValue( c1.dom.css.experimental(style) );
}
for (var i in style) this.css(el,i,style[i]);
} else {
// setter
if (styleObj[style] !== undefined) {
el.style[style] = value;
} else {
el.style[c1.dom.css.experimental(style)] = value;
}
}
};
var vendor = false;
c1.dom.css.experimental = function(style) {
if (styleObj[style] !== undefined) return style;
if (vendor) return styleObj['-'+vendor+'-'+style] !== undefined ? '-'+vendor+'-'+style : undefined;
for (var v in vendors) {
if (styleObj['-'+v+'-'+style] !== undefined) {
vendor = v;
return '-'+vendor+'-'+style;
}
}
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment