Scoped Property Store
Stores and retrieves properties associated with CSS selectors.
Currently, this library only supports the combinations of the following elements. More could be added pretty easily.
- Element names:
div
- Class names:
.foo
- Simple attributes:
[foo=bar]
- Descendant selectors:
.foo .bar
- Child selectors:
.foo > .bar
Usage:
ScopedPropertyScore = require 'scoped-property-store'store = # First associate some properties with selectors disposable = storeaddProperties 'some-description' '.foo.bar .baz': x: y: 1 z: 2 '.foo': x: y: 3 # Then query properties based on a string description of a path in the DOM. storeget'div.foo.bar p.baz''x.y' # ==> 1 storeget'div.foo.bar p.baz''x.z' # ==> 2 # Falls back to selectors matching an *ancestor* if necessary storeget'div.foo p.baz''x.y' # ==> 3 # You can also remove properties via the returned Disposable disposabledispose