How to use the sizzle.selectors function in sizzle

To help you get started, we’ve selected a few sizzle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github instructure / instructure-ui / packages / ui-test-utils / src / utils / selectors.js View on Github external
// :withLabel(text)
  Sizzle.selectors.pseudos.withLabel = createPseudo((text) => {
    return (element) => {
      return matchElementByLabel(element, text, options)
    }
  })
  Sizzle.selectors.pseudos.label = Sizzle.selectors.pseudos.withLabel

  // :withText(text)
  Sizzle.selectors.pseudos.withText = createPseudo((text) => {
    return (element) => {
      return matchElementByText(element, text, options)
    }
  })
  Sizzle.selectors.pseudos.textContent = Sizzle.selectors.pseudos.withText

  // :withTitle(text)
  Sizzle.selectors.pseudos.withTitle = createPseudo((text) => {
    return (element) => {
      return matchElementByTitle(element, text, options)
    }
  })
  Sizzle.selectors.pseudos.title = Sizzle.selectors.pseudos.withTitle

  // :clickable
  Sizzle.selectors.pseudos.clickable = (element) => {
    return clickable(element)
  }

  // :focusable
  Sizzle.selectors.pseudos.focusable = (element) => {
github instructure / instructure-ui / packages / ui-test-utils / src / utils / selectors.js View on Github external
function addPseudos (
  options = {
    exact: true,
    trim: true,
    collapseWhitespace: true
  }
) {
  const { createPseudo } = Sizzle.selectors

  // :withLabel(text)
  Sizzle.selectors.pseudos.withLabel = createPseudo((text) => {
    return (element) => {
      return matchElementByLabel(element, text, options)
    }
  })
  Sizzle.selectors.pseudos.label = Sizzle.selectors.pseudos.withLabel

  // :withText(text)
  Sizzle.selectors.pseudos.withText = createPseudo((text) => {
    return (element) => {
      return matchElementByText(element, text, options)
    }
  })
  Sizzle.selectors.pseudos.textContent = Sizzle.selectors.pseudos.withText
github instructure / instructure-ui / packages / ui-test-utils / src / utils / selectors.js View on Github external
import {
  tabbable,
  focusable,
  clickable,
  visible,
  exists
} from './helpers'

import {
  matchElementByTitle,
  matchElementByLabel,
  matchElementByText
} from './matchers'

Sizzle.selectors.cacheLength = 1

function querySelectorAll (...args) {
  const { element, selector, options } = parseQueryArguments(...args)

  let results = []

  if (selector) {
    results = findAllMatches(element, selector, options)
  } else {
    throwQueryError(element, selector)
  }

  return results
}

function querySelector (...args) {

sizzle

A pure-JavaScript, bottom-up CSS selector engine designed to be easily dropped in to a host library.

MIT
Latest version published 2 years ago

Package Health Score

65 / 100
Full package analysis