css-what

WebJar for css-what

License

License

BSD-2-Clause
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

css-what
Last Version

Last Version

4.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

css-what
WebJar for css-what
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/fb55/css-what

Download css-what

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/css-what/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>css-what</artifactId>
    <version>4.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/css-what/
implementation 'org.webjars.npm:css-what:4.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/css-what/
implementation ("org.webjars.npm:css-what:4.0.0")
'org.webjars.npm:css-what:jar:4.0.0'
<dependency org="org.webjars.npm" name="css-what" rev="4.0.0">
  <artifact name="css-what" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='css-what', version='4.0.0')
)
libraryDependencies += "org.webjars.npm" % "css-what" % "4.0.0"
[org.webjars.npm/css-what "4.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

css-what Build Status

a CSS selector parser

Example

const CSSwhat = require("css-what")
CSSwhat.parse("foo[bar]:baz")

~> [
    [
        { type: "tag", name: "foo" },
        {
            type: "attribute",
            name: "bar",
            action: "exists",
            value: "",
            ignoreCase: false
        },
        { type: "pseudo", name: "baz", data: null }
    ]
]

API

CSSwhat.parse(selector, options) - Parses selector, optionally with the passed options.

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' }

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.


License: BSD-2-Clause

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

css-what for enterprise

Available as part of the Tidelift Subscription

The 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.

Versions

Version
4.0.0
2.1.3
2.1.2
2.1.0
1.0.0