css-what

  • Version 5.0.1
  • Published
  • 32.4 kB
  • No dependencies
  • BSD-2-Clause license

Install

npm i css-what
yarn add css-what
pnpm add css-what

Overview

a CSS selector parser

Index

Functions

function isTraversal

isTraversal: (selector: Selector) => selector is Traversal;
  • Checks whether a specific selector is a traversal. This is useful eg. in swapping the order of elements that are not traversals.

    Parameter selector

    Selector to check.

function parse

parse: (selector: string, options?: Options) => Selector[][];
  • Parses selector, optionally with the passed options.

    Parameter selector

    Selector to parse.

    Parameter options

    Options for parsing.

    Returns

    Returns a two-dimensional array. The first dimension represents selectors separated by commas (eg. sub1, sub2), the second contains the relevant tokens for that selector.

function stringify

stringify: (selector: Selector[][]) => string;
  • Turns selector back into a string.

    Parameter selector

    Selector to stringify.

Interfaces

interface AttributeSelector

interface AttributeSelector {}

    property action

    action: AttributeAction;

      property ignoreCase

      ignoreCase: boolean | null;

        property name

        name: string;

          property namespace

          namespace: string | null;

            property type

            type: 'attribute';

              property value

              value: string;

                interface Options

                interface Options {}

                  property lowerCaseAttributeNames

                  lowerCaseAttributeNames?: boolean;
                  • When false, tag names will not be lowercased. true

                  property lowerCaseTags

                  lowerCaseTags?: boolean;
                  • When false, attribute names will not be lowercased. true

                  property xmlMode

                  xmlMode?: boolean;
                  • When true, xmlMode implies both lowerCaseTags and lowerCaseAttributeNames are set to false. Also, ignoreCase on attributes will not be inferred based on HTML rules anymore. false

                  interface PseudoElement

                  interface PseudoElement {}

                    property name

                    name: string;

                      property type

                      type: 'pseudo-element';

                        interface PseudoSelector

                        interface PseudoSelector {}

                          property data

                          data: DataType;

                            property name

                            name: string;

                              property type

                              type: 'pseudo';

                                interface TagSelector

                                interface TagSelector {}

                                  property name

                                  name: string;

                                    property namespace

                                    namespace: string | null;

                                      property type

                                      type: 'tag';

                                        interface Traversal

                                        interface Traversal {}

                                          property type

                                          type: TraversalType;

                                            interface UniversalSelector

                                            interface UniversalSelector {}

                                              property namespace

                                              namespace: string | null;

                                                property type

                                                type: 'universal';

                                                  Type Aliases

                                                  type AttributeAction

                                                  type AttributeAction =
                                                  | 'any'
                                                  | 'element'
                                                  | 'end'
                                                  | 'equals'
                                                  | 'exists'
                                                  | 'hyphen'
                                                  | 'not'
                                                  | 'start';

                                                    type Selector

                                                    type Selector =
                                                    | PseudoSelector
                                                    | PseudoElement
                                                    | AttributeSelector
                                                    | TagSelector
                                                    | UniversalSelector
                                                    | Traversal;

                                                      type TraversalType

                                                      type TraversalType = 'adjacent' | 'child' | 'descendant' | 'parent' | 'sibling';

                                                        Package Files (3)

                                                        Dependencies (0)

                                                        No dependencies.

                                                        Dev Dependencies (12)

                                                        Peer Dependencies (0)

                                                        No peer dependencies.

                                                        Badge

                                                        To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                        You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/css-what.

                                                        • Markdown
                                                          [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/css-what)
                                                        • HTML
                                                          <a href="https://www.jsdocs.io/package/css-what"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>