How to use the autoprefixer/lib/browsers function in autoprefixer

To help you get started, we’ve selected a few autoprefixer 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 stylelint / stylelint / src / utils / isAutoprefixable.js View on Github external
import Browsers from "autoprefixer/lib/browsers"
import Prefixes from "autoprefixer/lib/prefixes"
import autoprefixer from "autoprefixer"

/**
 * Use Autoprefixer's secret powers to determine whether or
 * not a certain CSS identifier contains a vendor prefix that
 * Autoprefixer, given the standardized identifier, could add itself.
 *
 * Used by `*-no-vendor-prefix-*` rules to find superfluous
 * vendor prefixes.
 */

const prefixes = new Prefixes(
  autoprefixer.data.prefixes,
  new Browsers(autoprefixer.data.browsers, [])
)

/**
 * Most identifier types have to be looked up in a unique way,
 * so we're exposing special functions for each.
 */
export default {

  atRuleName(identifier) {
    return prefixes.remove[`@${identifier.toLowerCase()}`]
  },

  selector(identifier) {
    return prefixes.remove.selectors.some(selectorObj => {
      return identifier.toLowerCase() === selectorObj.prefixed
    })