css-select

  • Version 4.1.3
  • Published
  • 77.7 kB
  • 5 dependencies
  • BSD-2-Clause license

Install

npm i css-select
yarn add css-select
pnpm add css-select

Overview

a CSS selector compiler/engine

Index

Variables

variable aliases

const aliases: Record<string, string>;
  • Aliases are pseudos that are expressed as selectors.

variable filters

const filters: Record<string, Filter>;

    variable pseudos

    const pseudos: Record<string, Pseudo>;

      Functions

      function compile

      compile: <Node_1, ElementNode extends Node_1>(
      selector: string | import('css-what').Selector[][],
      options?: Options<Node_1, ElementNode>,
      context?: Node_1 | Node_1[]
      ) => CompiledQuery<Node_1>;
      • Compiles the query, returns a function.

      function is

      is: <Node, ElementNode extends Node>(
      elem: ElementNode,
      query: Query<ElementNode>,
      options?: Options<Node, ElementNode>
      ) => boolean;
      • Tests whether or not an element is matched by query.

        Node The generic Node type for the DOM adapter being used. ElementNode The Node type for elements for the DOM adapter being used.

        Parameter elem

        The element to test if it matches the query.

        Parameter query

        can be either a CSS selector string or a compiled query function.

        Parameter options

        options for querying the document.

        Returns

        See Also

        • compile for supported selector queries.

      function prepareContext

      prepareContext: <Node, ElementNode extends Node>(
      elems: Node | Node[],
      adapter: Adapter<Node, ElementNode>,
      shouldTestNextSiblings?: boolean
      ) => Node[];

        function selectAll

        selectAll: <Node_1, ElementNode extends Node_1>(
        query: Query<ElementNode>,
        elements: Node_1 | Node_1[],
        options?: Options<Node_1, ElementNode>
        ) => ElementNode[];
        • Node The generic Node type for the DOM adapter being used. ElementNode The Node type for elements for the DOM adapter being used.

          Parameter elems

          Elements to query. If it is an element, its children will be queried..

          Parameter query

          can be either a CSS selector string or a compiled query function.

          Parameter options

          options for querying the document.

          Returns

          All matching elements.

          See Also

          • compile for supported selector queries.

        function selectOne

        selectOne: <Node_1, ElementNode extends Node_1>(
        query: Query<ElementNode>,
        elements: Node_1 | Node_1[],
        options?: Options<Node_1, ElementNode>
        ) => ElementNode;
        • Node The generic Node type for the DOM adapter being used. ElementNode The Node type for elements for the DOM adapter being used.

          Parameter elems

          Elements to query. If it is an element, its children will be queried..

          Parameter query

          can be either a CSS selector string or a compiled query function.

          Parameter options

          options for querying the document.

          Returns

          the first match, or null if there was no match.

          See Also

          • compile for supported selector queries.

        Interfaces

        interface Options

        interface Options<Node, ElementNode extends Node> {}

          property adapter

          adapter?: Adapter<Node, ElementNode>;
          • The adapter to use when interacting with the backing DOM structure. By default it uses the domutils module.

          property cacheResults

          cacheResults?: boolean;
          • Allow css-select to cache results for some selectors, sometimes greatly improving querying performance. Disable this if your document can change in between queries with the same compiled selector.

            true

          property context

          context?: Node | Node[];
          • The context of the current query. Used to limit the scope of searches. Can be matched directly using the :scope pseudo-selector.

          property rootFunc

          rootFunc?: (element: ElementNode) => boolean;
          • The last function in the stack, will be called with the last element that's looked at.

          property xmlMode

          xmlMode?: boolean;
          • When enabled, tag names will be case-sensitive.

            false

          Package Files (5)

          Dependencies (5)

          Dev Dependencies (14)

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

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