# get-css-data
[![NPM](https://img.shields.io/npm/v/get-css-data.svg?style=flat-square)](https://www.npmjs.com/package/get-css-data)
[![GitHub Workflow Status (master)](https://img.shields.io/github/actions/workflow/status/jhildenbiddle/get-css-data/test.yml?branch=master&label=checks&style=flat-square)](https://github.com/jhildenbiddle/get-css-data/actions?query=branch%3Amaster+)
[![Codacy code quality](https://img.shields.io/codacy/grade/ec8f2d2595804ab38ad138b762a640e6/master?style=flat-square)](https://app.codacy.com/gh/jhildenbiddle/get-css-data/dashboard?branch=master)
[![Codacy branch coverage](https://img.shields.io/codacy/coverage/ec8f2d2595804ab38ad138b762a640e6/master?style=flat-square)](https://app.codacy.com/gh/jhildenbiddle/get-css-data/dashboard?branch=master)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://github.com/jhildenbiddle/get-css-data/blob/master/LICENSE)
[![Sponsor this project](https://img.shields.io/static/v1?style=flat-square&label=Sponsor&message=%E2%9D%A4&logo=GitHub&color=%23fe8e86)](https://github.com/sponsors/jhildenbiddle)
A micro-library for collecting stylesheet data from link and style nodes.
## Features
- Collects CSS data from `` and `
```
CSS:
```css
/* style1.css */
p { color: red; }
```
```css
/* style2.css */
p { color: green; }
```
JavaScript (see [Options](#options) for details)
```javascript
getCssData({
onComplete: function(cssText, cssArray, nodeArray) {
console.log(cssText); // 1
console.log(cssArray); // 2
console.log(nodeArray); // 3
}
});
// 1 => 'p { color: red; } p { color: green; } p { color: blue; }'
// 2 => ['p { color: red; }', 'p { color: green; } p { color: blue; }']
// 3 => [, ]
```
## Options
- [rootElement](#optionsrootelement)
- [include](#optionsinclude)
- [exclude](#optionsexclude)
- [filter](#optionsfilter)
- [skipDisabled](#optionsskipdisabled)
- [useCSSOM](#optionsusecssom)
- [onBeforeSend](#optionsonbeforesend)
- [onSuccess](#optionsonsuccess)
- [onError](#optionsonerror)
- [onComplete](#optionsoncomplete)
**Example**
```javascript
// Default values shown
getCssData({
rootElement : document,
include : 'link[rel=stylesheet],style',
exclude : '',
filter : '',
skipDisabled: true,
useCSSOM : false,
onBeforeSend: function(xhr, node, url) {
// ...
},
onSuccess: function(cssText, node, url) {
// ...
},
onError: function(xhr, node, url) {
// ...
},
onComplete: function(cssText, cssArray, nodeArray) {
// ...
}
});
```
### options.rootElement
- Type: `object`
- Default: `document`
Root element to traverse for `` and `