Created
August 14, 2020 13:35
-
-
Save seyedi/10c09059696667cd67f502a7b3164fb8 to your computer and use it in GitHub Desktop.
Dynamically compute list of supported properties
This file contains hidden or 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
// Credit: https://codepen.io/leaverou/pen/eYJodjb | |
let style = document.body.style; | |
let properties = Object.getOwnPropertyNames(style.hasOwnProperty("background")? style : style.__proto__); | |
properties = properties.filter(p => style[p] === "") // drop functions etc | |
.map(prop => { // de-camelCase | |
prop = prop.replace(/[A-Z]/g, function($0) { return '-' + $0.toLowerCase() }); | |
if (prop.indexOf("webkit-") > -1) { | |
prop = "-" + prop; | |
} | |
return prop; | |
}); | |
output.textContent = JSON.stringify(properties, null, "\t"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment