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