css-what
Advanced tools
Comparing version 5.1.0 to 6.0.0
@@ -5,3 +5,3 @@ { | ||
"description": "a CSS selector parser", | ||
"version": "5.1.0", | ||
"version": "6.0.0", | ||
"funding": { | ||
@@ -11,6 +11,9 @@ "url": "https://github.com/sponsors/fb55" | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/fb55/css-what" | ||
}, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "lib/commonjs/index.js", | ||
"module": "lib/es/index.js", | ||
"types": "lib/es/index.d.ts", | ||
"sideEffects": false, | ||
"files": [ | ||
@@ -29,19 +32,18 @@ "lib/**/*" | ||
"prettier": "prettier '**/*.{ts,md,json,yml}'", | ||
"build": "tsc", | ||
"build": "tsc && tsc -p tsconfig.es.json", | ||
"prepare": "npm run build" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.0.2", | ||
"@types/node": "^16.10.3", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"eslint": "^7.32.0", | ||
"@types/jest": "^27.0.3", | ||
"@types/node": "^17.0.4", | ||
"@typescript-eslint/eslint-plugin": "^5.8.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"jest": "^27.2.4", | ||
"prettier": "^2.4.1", | ||
"ts-jest": "^27.0.5", | ||
"typescript": "^4.4.3" | ||
"jest": "^27.4.5", | ||
"prettier": "^2.5.1", | ||
"ts-jest": "^27.1.2", | ||
"typescript": "^4.5.4" | ||
}, | ||
"optionalDependencies": {}, | ||
"engines": { | ||
@@ -52,3 +54,6 @@ "node": ">= 6" | ||
"jest": { | ||
"preset": "ts-jest" | ||
"preset": "ts-jest", | ||
"roots": [ | ||
"src" | ||
] | ||
}, | ||
@@ -55,0 +60,0 @@ "prettier": { |
@@ -1,9 +0,13 @@ | ||
# css-what [![Build Status](https://secure.travis-ci.org/fb55/css-what.svg?branch=master)](http://travis-ci.org/fb55/css-what) | ||
# css-what | ||
a CSS selector parser | ||
[![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) | ||
[![Coverage](https://img.shields.io/coveralls/github/fb55/css-what/master)](https://coveralls.io/github/fb55/css-what?branch=master) | ||
A CSS selector parser. | ||
## Example | ||
```js | ||
const CSSwhat = require("css-what") | ||
import * as CSSwhat from "css-what"; | ||
CSSwhat.parse("foo[bar]:baz") | ||
@@ -19,3 +23,3 @@ | ||
value: "", | ||
ignoreCase: false | ||
ignoreCase: null | ||
}, | ||
@@ -29,29 +33,24 @@ { type: "pseudo", name: "baz", data: null } | ||
**`CSSwhat.parse(selector, options)` - Parses `selector`, optionally with the passed `options`.** | ||
**`CSSwhat.parse(selector)` - Parses `selector`.** | ||
The 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: | ||
| name | properties | example | output | | ||
| ---------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- | | ||
| `tag` | `name` | `div` | `{ type: 'tag', name: 'div' }` | | ||
| `universal` | - | `*` | `{ type: 'universal' }` | | ||
| `pseudo` | `name`, `data` | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }` | | ||
| `pseudo` | `name`, `data` | `:name` | `{ type: 'pseudo', name: 'name', data: null }` | | ||
| `pseudo-element` | `name` | `::name` | `{ type: 'pseudo-element', name: 'name' }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr]` | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr=val]` | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }` | | ||
| `child` | - | `>` | `{ type: 'child' }` | | ||
| `parent` | - | `<` | `{ type: 'parent' }` | | ||
| `sibling` | - | `~` | `{ type: 'sibling' }` | | ||
| `adjacent` | - | `+` | `{ type: 'adjacent' }` | | ||
| `descendant` | - | | `{ type: 'descendant' }` | | ||
| name | properties | example | output | | ||
| ------------------- | --------------------------------------- | ------------- | ---------------------------------------------------------------------------------------- | | ||
| `tag` | `name` | `div` | `{ type: 'tag', name: 'div' }` | | ||
| `universal` | - | `*` | `{ type: 'universal' }` | | ||
| `pseudo` | `name`, `data` | `:name(data)` | `{ type: 'pseudo', name: 'name', data: 'data' }` | | ||
| `pseudo` | `name`, `data` | `:name` | `{ type: 'pseudo', name: 'name', data: null }` | | ||
| `pseudo-element` | `name` | `::name` | `{ type: 'pseudo-element', name: 'name' }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr]` | `{ type: 'attribute', name: 'attr', action: 'exists', value: '', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr=val]` | `{ type: 'attribute', name: 'attr', action: 'equals', value: 'val', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr^=val]` | `{ type: 'attribute', name: 'attr', action: 'start', value: 'val', ignoreCase: false }` | | ||
| `attribute` | `name`, `action`, `value`, `ignoreCase` | `[attr$=val]` | `{ type: 'attribute', name: 'attr', action: 'end', value: 'val', ignoreCase: false }` | | ||
| `child` | - | `>` | `{ type: 'child' }` | | ||
| `parent` | - | `<` | `{ type: 'parent' }` | | ||
| `sibling` | - | `~` | `{ type: 'sibling' }` | | ||
| `adjacent` | - | `+` | `{ type: 'adjacent' }` | | ||
| `descendant` | - | | `{ type: 'descendant' }` | | ||
| `column-combinator` | - | `\|\|` | `{ type: 'column-combinator' }` | | ||
**Options:** | ||
- `lowerCaseTags`: When false, tag names will not be lowercased. Defaults to `true`. | ||
- `lowerCaseAttributeNames`: When false, attribute names will not be lowercased. Defaults to `true`. | ||
- `xmlMode`: When `true`, `xmlMode` implies both `lowerCaseTags` and `lowerCaseAttributeNames` are set to `false`. | ||
**`CSSwhat.stringify(selector)` - Turns `selector` back into a string.** | ||
@@ -58,0 +57,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
65672
27
1394
70
1