A javascript function to retrieve all the css rules associated with a DOM element
cssMatcher(document.body,styles)
element
the DOM element
styles
The styleSheets property present in the return value of css-mapper
an object with the following properties:
ancestors : an array of objects that map all the CSSStyleRules associated with the ancestor
elements,structured as follows:
truetruetrueisStylecssMatches, with the difference that inheritedProps will be valorized to true
and the properties inside the properties object will have ‘isInherited’ setted to true
cssMatches : an array of objects that map all the CSSStyleRules associated with the element, structured as follows
isStyle, it will not be setted
false
or undefinedfalseisStyle, othherwise the CSSStyleRule
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
This project uses the following libraries:
At the moment there are not automated tests for this part. However, you can test manually in test.html or in pseudosTest.html.