1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 05:17:16 -04:00
notes/node_modules/stylelint/lib/utils/isAutoprefixable.js

51 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
/* @flow */
"use strict"
const Browsers = require("autoprefixer/lib/browsers")
const Prefixes = require("autoprefixer/lib/prefixes")
const autoprefixer = require("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.
*/
module.exports = {
atRuleName(identifier/*: string*/)/*: boolean*/ {
return prefixes.remove[`@${identifier.toLowerCase()}`]
},
selector(identifier/*: string*/)/*: boolean*/ {
return prefixes.remove.selectors.some(selectorObj => {
return identifier.toLowerCase() === selectorObj.prefixed
})
},
mediaFeatureName(identifier/*: string*/)/*: boolean*/ {
return identifier.toLowerCase().indexOf("device-pixel-ratio") !== -1
},
property(identifier/*: string*/)/*: boolean*/ {
return autoprefixer.data.prefixes[prefixes.unprefixed(identifier.toLowerCase())]
},
propertyValue(prop/*: string*/, value/*: string*/)/*: boolean*/ {
const possiblePrefixableValues = prefixes.remove[prop.toLowerCase()] && prefixes.remove[prop.toLowerCase()].values
return possiblePrefixableValues && possiblePrefixableValues.some(valueObj => {
return value.toLowerCase() === valueObj.prefixed
})
},
}