Created
July 12, 2018 08:15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!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