Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
!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
You can’t perform that action at this time.