Skip to content

Instantly share code, notes, and snippets.

@a1exlism
Created March 18, 2018 08:41
Show Gist options
  • Save a1exlism/d8e5f05245ba5f6466408cac623c3344 to your computer and use it in GitHub Desktop.
Save a1exlism/d8e5f05245ba5f6466408cac623c3344 to your computer and use it in GitHub Desktop.
function styleHyphenFormat(propertyName) {
function upperToHyphenLower(match) {
return '-' + match.toLowerCase();
}
return propertyName.replace(/[A-Z]/g, upperToHyphenLower);
}
function cssStyle2DomStyle(sName) {
let result = sName.replace(/-\w/g, function (match) {
return match.slice(1).toUpperCase();
});
return result.charAt(0).toLowerCase() + result.slice(1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment