Skip to content

Instantly share code, notes, and snippets.

@DavidAnson
Created November 4, 2017 21:32
Show Gist options
  • Save DavidAnson/e5862b4a802d0e153942269365cddcb6 to your computer and use it in GitHub Desktop.
Save DavidAnson/e5862b4a802d0e153942269365cddcb6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>CSS property names having longest overlap with hexadecimal color characters</title>
</head>
<body>
<pre><script>
r = []
for (s in getComputedStyle(document.body)) {
s = s.toLowerCase()
m = !/^webkit/.test(s) && /[abcdef]{3,}/.exec(s)
m && r.push([m[0].length, m[0], s])
}
r.sort((a, b) => (b[0]-a[0]) || a[1].localeCompare(b[1]))
r.forEach(e => document.write(e + "\n"))
</script></pre>
</body>
</html>
@DavidAnson
Copy link
Author

Self-review: RegExp should be global to find all the matches in the style name (vs. just the first of sufficient length).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment