Created
May 23, 2015 04:50
-
-
Save albertywu/5a82b9ac1cd18282330a to your computer and use it in GitHub Desktop.
Short snippet that returns an array of unique classes in the DOM
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
| /* returns an array of unique classes in the DOM */ | |
| var getUniqueClasses = function() { | |
| var elementArray = [].slice.call(document.querySelectorAll('*')); | |
| return _(elementArray) | |
| .pluck('classList') | |
| .map(_.toArray) | |
| .flatten() | |
| .unique() | |
| .value() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment