Created
February 13, 2012 11:15
-
-
Save philippeantoine/1816126 to your computer and use it in GitHub Desktop.
prefixes.js
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
<!doctype html> | |
<html><meta charset="UTF-8"><head><title>prefixes</title></head> | |
<body> | |
<p>prefixes</p> | |
<style> | |
p{ | |
-beta-transform: scaleY(2); | |
-alpha-text-stroke: 1px grey; | |
font: 25px sans-serif; | |
} | |
</style> | |
<script> | |
var prefixes = { | |
vendor: '-webkit-', | |
replace: function(){ | |
for (var i = 0;i < document.styleSheets.length;i++){ | |
for (var j = 0;j < document.styleSheets[i].cssRules.length;j++){ | |
var CSSStyleDeclaration = document.styleSheets[i].cssRules[j].style; | |
for (var k = 0;k < CSSStyleDeclaration.length;k++){ | |
var declaration = CSSStyleDeclaration[k]; | |
var cssText = CSSStyleDeclaration.cssText; | |
if (declaration.indexOf( '-alpha-') === 0){ | |
var cssValue = cssText.split(declaration +':')[1].split(';')[0]; | |
var newVendorSpecificProperty = this.vendor; | |
newVendorSpecificProperty += declaration.split( '-alpha-').pop(); | |
CSSStyleDeclaration.setProperty(newVendorSpecificProperty, cssValue); | |
} else if (declaration.indexOf( '-beta-') === 0){ | |
var cssValue = cssText.split(declaration +':')[1].split(';')[0]; | |
var newVendorSpecificProperty = this.vendor; | |
newVendorSpecificProperty += declaration.split( '-beta-').pop(); | |
CSSStyleDeclaration.setProperty(newVendorSpecificProperty, cssValue); | |
} | |
} | |
} | |
} | |
} | |
}; | |
prefixes.replace(); | |
</script> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment