UNPKG

971 BJavaScriptView Raw
1'use strict';
2
3/**
4 * Contains helpers for working with vendor prefixes.
5 *
6 * Copied from https://github.com/postcss/postcss/commit/777c55b5d2a10605313a4972888f4f32005f5ac2
7 *
8 * @namespace vendor
9 */
10module.exports = {
11 /**
12 * Returns the vendor prefix extracted from an input string.
13 *
14 * @param {string} prop String with or without vendor prefix.
15 *
16 * @return {string} vendor prefix or empty string
17 *
18 * @example
19 * vendor.prefix('-moz-tab-size') //=> '-moz-'
20 * vendor.prefix('tab-size') //=> ''
21 */
22 prefix(prop) {
23 let match = prop.match(/^(-\w+-)/);
24
25 if (match) {
26 return match[0];
27 }
28
29 return '';
30 },
31
32 /**
33 * Returns the input string stripped of its vendor prefix.
34 *
35 * @param {string} prop String with or without vendor prefix.
36 *
37 * @return {string} String name without vendor prefixes.
38 *
39 * @example
40 * vendor.unprefixed('-moz-tab-size') //=> 'tab-size'
41 */
42 unprefixed(prop) {
43 return prop.replace(/^-\w+-/, '');
44 },
45};