• Home
Name Date Size #Lines LOC

..--

src/12-May-2024-19,46419,228

.eslintrc.jsonD12-May-20242.5 KiB7371

.gitattributesD12-May-2024631 1615

.prettierignoreD12-May-202429 43

BUILD.gnD12-May-2024760 2118

LICENSED12-May-20241.2 KiB127

OAT.xmlD12-May-20244.1 KiB7115

README.OpenSourceD12-May-2024308 1211

bundle.jsonD12-May-2024769 3535

package-lock.jsonD12-May-2024391.2 KiB9,0699,068

package.jsonD12-May-20241.7 KiB6059

readme.mdD12-May-20244.6 KiB7051

tsconfig.es.jsonD12-May-2024188 109

tsconfig.eslint.jsonD12-May-202480 65

tsconfig.jsonD12-May-20241.9 KiB3531

README.OpenSource

1[
2    {
3        "Name": "css-what",
4        "License": "BSD 2-Clause License",
5        "License File": "LICENSE",
6        "Version Number": "v6.1.0",
7        "Owner": "lixingchi1@huawei.com",
8        "Upstream URL": "https://github.com/fb55/css-what",
9        "Description": "a CSS selector parser."
10    }
11]
12

readme.md

1# css-what
2
3[![Build Status](https://img.shields.io/github/workflow/status/fb55/css-what/Node.js%20CI/master)](https://github.com/fb55/css-what/actions/workflows/nodejs-test.yml)
4[![Coverage](https://img.shields.io/coveralls/github/fb55/css-what/master)](https://coveralls.io/github/fb55/css-what?branch=master)
5
6A CSS selector parser.
7
8## Example
9
10```js
11import * as CSSwhat from "css-what";
12
13CSSwhat.parse("foo[bar]:baz")
14
15~> [
16    [
17        { type: "tag", name: "foo" },
18        {
19            type: "attribute",
20            name: "bar",
21            action: "exists",
22            value: "",
23            ignoreCase: null
24        },
25        { type: "pseudo", name: "baz", data: null }
26    ]
27]
28```
29
30## API
31
32**`CSSwhat.parse(selector)` - Parses `selector`.**
33
34The function returns a two-dimensional array. The first array represents selectors separated by commas (eg. `sub1, sub2`), the second contains the relevant tokens for that selector. Possible token types are:
35
36| name                | properties                              | example       | output                                                                                   |
37| ------------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- |
38| `tag`               | `name`                                  | `div`         | `{ type: 'tag', name: 'div' }`                                                           |
39| `universal`         | -                                       | `*`           | `{ type: 'universal' }`                                                                  |
40| `pseudo`            | `name`, `data`                          | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }`                                         |
41| `pseudo`            | `name`, `data`                          | `:name`       | `{ type: 'pseudo', name: 'name', data: null }`                                           |
42| `pseudo-element`    | `name`                                  | `::name`      | `{ type: 'pseudo-element', name: 'name' }`                                               |
43| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr]`      | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }`    |
44| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr=val]`  | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` |
45| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }`  |
46| `attribute`         | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }`    |
47| `child`             | -                                       | `>`           | `{ type: 'child' }`                                                                      |
48| `parent`            | -                                       | `<`           | `{ type: 'parent' }`                                                                     |
49| `sibling`           | -                                       | `~`           | `{ type: 'sibling' }`                                                                    |
50| `adjacent`          | -                                       | `+`           | `{ type: 'adjacent' }`                                                                   |
51| `descendant`        | -                                       |               | `{ type: 'descendant' }`                                                                 |
52| `column-combinator` | -                                       | `\|\|`        | `{ type: 'column-combinator' }`                                                          |
53
54**`CSSwhat.stringify(selector)` - Turns `selector` back into a string.**
55
56---
57
58License: BSD-2-Clause
59
60## Security contact information
61
62To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
63Tidelift will coordinate the fix and disclosure.
64
65## `css-what` for enterprise
66
67Available as part of the Tidelift Subscription
68
69The maintainers of `css-what` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-css-what?utm_source=npm-css-what&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
70