mazey
    Preparing search index...

    Function isValidCssSelector

    • Check whether a value is a CSS selector supported by the supplied query root without allowing selector syntax errors to escape.

      Usage:

      import { isValidCssSelector } from "mazey";

      isValidCssSelector(".message > img"); // true
      isValidCssSelector("["); // false
      isValidCssSelector("", { allowEmpty: true }); // true

      Parameters

      • selector: unknown

        Value to validate as a CSS selector.

      • options: { allowEmpty?: boolean; root?: ParentNode } = {}
        • OptionalallowEmpty?: boolean

          Whether an empty or whitespace-only string is accepted. Defaults to false.

        • Optionalroot?: ParentNode

          Query root used to validate browser support. Defaults to document when available.

      Returns boolean

      Whether the selector is accepted by the query root.

      Browser only unless a compatible ParentNode is supplied.