mu-lib/mu-selector-set — pull request #5 by EyalAr (2014-11-04 02:02:56+00:00)
Title: Modularize the code

Components:

0. Classifier - takes a selector string and returns the most significant part of the rightmost selector by the following priority:
0. ID
0. Class
0. Tag
0. Other
0. Mapped List - A simple construct to manage lists by keys. Much like a hash map with key-value pairs, this map has key-list pairs.
0. Matches Selector - A service function which takes an element and a selector and returns `true` if the element matches the selector or `false` otherwise. This function tries to use native browser `*matchesSelector` functions, and falls back to a simple polyfill.
0. Subsets - A "Subset" object encapsulates all the functionalities required to manage a certain type (subset) of selectors. We have 4 subsets: *IDs*, *classes*, *tags* and *others*. A Subset is backed by a MappedList object. It provides the following functions:
0. `isOfType` - Takes a selector string and returns `true` if the selector is of the type of this subset. `false` otherwise.
0. `extractElementKeys` - Takes a DOM element and return a string of keys of this elements that match this subset. For example, in the *IDs* subset this method will return an array with at most one value - the element's id.
0. `add` - Adds data to the subset under a certain key.
0. `get` - Gets data from the subset under a certain key.
0. Selector Set - The main module. Provides the following methods:
0. `add` - Add a selector to the set.
0. `matches` - Takes a DOM element and returns a list of selectors (and any associated data) that this element matches.