Skip to content

Instantly share code, notes, and snippets.

@seyedi
Created August 14, 2020 13:35
Show Gist options
  • Save seyedi/10c09059696667cd67f502a7b3164fb8 to your computer and use it in GitHub Desktop.
Save seyedi/10c09059696667cd67f502a7b3164fb8 to your computer and use it in GitHub Desktop.
Dynamically compute list of supported properties
// 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