CSS MATCHER

A javascript function to retrieve all the css rules associated with a DOM element

cssMatcher(document.body,styles)

Parameters

element
    the DOM element
styles
    The styleSheets property present in the return value of css-mapper

Return value

an object with the following properties:
ancestors : an array of objects that map all the CSSStyleRules associated with the ancestor elements,structured as follows:

cssMatches : an array of objects that map all the CSSStyleRules associated with the element, structured as follows

properties: a list of all the css properties retrieved from all the rules that match the element.
pseudoStates: an array of objects similar to cssMatches, with the property pseudos that is an array of some pseudo classes associated with the rule. The pseudo classes are :hover|:active|:focus|:focus-within|:visited.
pseudoElements: an array of objects similar to cssMatches, with the property pseudos that is an array of all the pseudo elements associated with the rule
getCssTextProperties: a function that parse all the properties present in a CSSStyleDeclaration.cssText string. This property is associated with window.getCssTextProperties
isShortHand: a function to verify if a css property is a css shorthand

Dependencies

This project uses the following libraries:

Running the tests

At the moment there are not automated tests for this part. However, you can test manually in test.html or in pseudosTest.html.