mirror of
https://github.com/hanzoai/postcss.git
synced 2026-09-24 17:01:56 +00:00
48 lines
999 B
JavaScript
48 lines
999 B
JavaScript
/**
|
|
* Contains helpers for working with vendor prefixes.
|
|
*
|
|
* @example
|
|
* const vendor = postcss.vendor
|
|
*
|
|
* @namespace vendor
|
|
*/
|
|
let vendor = {
|
|
|
|
/**
|
|
* Returns the vendor prefix extracted from an input string.
|
|
*
|
|
* @param {string} prop String with or without vendor prefix.
|
|
*
|
|
* @return {string} vendor prefix or empty string
|
|
*
|
|
* @example
|
|
* postcss.vendor.prefix('-moz-tab-size') //=> '-moz-'
|
|
* postcss.vendor.prefix('tab-size') //=> ''
|
|
*/
|
|
prefix (prop) {
|
|
let match = prop.match(/^(-\w+-)/)
|
|
if (match) {
|
|
return match[0]
|
|
}
|
|
|
|
return ''
|
|
},
|
|
|
|
/**
|
|
* Returns the input string stripped of its vendor prefix.
|
|
*
|
|
* @param {string} prop String with or without vendor prefix.
|
|
*
|
|
* @return {string} String name without vendor prefixes.
|
|
*
|
|
* @example
|
|
* postcss.vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
|
|
*/
|
|
unprefixed (prop) {
|
|
return prop.replace(/^-\w+-/, '')
|
|
}
|
|
|
|
}
|
|
|
|
export default vendor
|