Last active
August 29, 2015 13:57
-
-
Save oslego/9878181 to your computer and use it in GitHub Desktop.
Converts a CSS property name to its DOM form. Removes dashes and upperacases the char following the dash.
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
/* | |
Takes a CSS property name string and returns its DOM notation. | |
@example: shape-inside -> shapeInside | |
@example: -webkit-shape-inside -> webkitShapeInside | |
@param {String} str CSS property name, possibly hyphenated. | |
@return {String} | |
*/ | |
function getDOMCSSProperty(str){ | |
// remove first dash if the property is prefixed | |
str = (str.indexOf("-") === 0) ? str.substr(1) : str; | |
// remove the dash and uppercase the char after the dash | |
return str.replace(/-(\S)/g, function(str, group){ | |
return group.toUpperCase(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment