source: trip-planner-front/node_modules/css-what/readme.md@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 4.6 KB
Line 
1# css-what [![Build Status](https://secure.travis-ci.org/fb55/css-what.svg?branch=master)](http://travis-ci.org/fb55/css-what)
2
3a CSS selector parser
4
5## Example
6
7```js
8const CSSwhat = require("css-what")
9CSSwhat.parse("foo[bar]:baz")
10
11~> [
12 [
13 { type: "tag", name: "foo" },
14 {
15 type: "attribute",
16 name: "bar",
17 action: "exists",
18 value: "",
19 ignoreCase: false
20 },
21 { type: "pseudo", name: "baz", data: null }
22 ]
23]
24```
25
26## API
27
28**`CSSwhat.parse(selector, options)` - Parses `selector`, optionally with the passed `options`.**
29
30The 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:
31
32| name | properties | example | output |
33| ---------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- |
34| `tag` | `name` | `div` | `{ type: 'tag', name: 'div' }` |
35| `universal` | - | `*` | `{ type: 'universal' }` |
36| `pseudo` | `name`, `data` | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }` |
37| `pseudo` | `name`, `data` | `:name` | `{ type: 'pseudo', name: 'name', data: null }` |
38| `pseudo-element` | `name` | `::name` | `{ type: 'pseudo-element', name: 'name' }` |
39| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr]` | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }` |
40| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr=val]` | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` |
41| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }` |
42| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }` |
43| `child` | - | `>` | `{ type: 'child' }` |
44| `parent` | - | `<` | `{ type: 'parent' }` |
45| `sibling` | - | `~` | `{ type: 'sibling' }` |
46| `adjacent` | - | `+` | `{ type: 'adjacent' }` |
47| `descendant` | - | | `{ type: 'descendant' }` |
48
49**Options:**
50
51- `lowerCaseTags`: When false, tag names will not be lowercased. Defaults to `true`.
52- `lowerCaseAttributeNames`: When false, attribute names will not be lowercased. Defaults to `true`.
53- `xmlMode`: When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`.
54
55**`CSSwhat.stringify(selector)` - Turns `selector` back into a string.**
56
57---
58
59License: BSD-2-Clause
60
61## Security contact information
62
63To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security).
64Tidelift will coordinate the fix and disclosure.
65
66## `css-what` for enterprise
67
68Available as part of the Tidelift Subscription
69
70The 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)
Note: See TracBrowser for help on using the repository browser.