How to use the css-what.parse function in css-what

To help you get started, we’ve selected a few css-what 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 ionic-team / stencil / src / mock-doc / selector.ts View on Github external
export function selectAll(selector: string, elm: MockElement) {
  const selectors = parse(selector);
  const foundElms: MockElement[] = [];
  selectAllRecursion(selectors, elm, foundElms);
  return foundElms;
}
github ionic-team / stencil / src / mock-doc / selector.ts View on Github external
export function matches(selector: string, elm: MockElement) {
  const selectors = parse(selector);
  return matchesSelectors(selectors, elm) !== null;
}
github ionic-team / stencil / src / mock-doc / selector.ts View on Github external
export function selectOne(selector: string, elm: MockElement) {
  const selectors = parse(selector);
  return selectOneRecursion(selectors, elm);
}
github fb55 / css-select / lib / compile.js View on Github external
function compileUnsafe(selector, options, context) {
    var token = parse(selector, options);
    return compileToken(token, options, context);
}
github NervJS / taro / packages / taro-cli / src / quickapp / style / selector / index.ts View on Github external
output.logs.push({
      reason: 'W:选择器`' + selector + '`不支持',
      line: rule.position.start.line,
      column: rule.position.start.column
    })
    return false
  }
  if (~selector.indexOf(':before') || ~selector.indexOf(':after') || ~selector.indexOf(':last-child') || ~selector.indexOf(':first-child')) {
    output.logs.push({
      reason: 'W:选择器`' + selector + '`不支持',
      line: rule.position.start.line,
      column: rule.position.start.column
    })
    return false
  }
  selector = cssWhat.parse(selector)[0].map(subselect => {
    if (subselect.type === 'descendant') {
      return ' '
    } else if (subselect.type === 'attribute') {
      if (subselect.name === 'class') {
        return '.' + subselect.value
      } else if (subselect.name === 'id') {
        return '#' + subselect.value
      }
    }
    return ''
  }).join('')
  return selector
}

css-what

a CSS selector parser

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

78 / 100
Full package analysis

Popular css-what functions