vendor.cjs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. /**
  5. * Contains helpers for working with vendor prefixes.
  6. *
  7. * Copied from https://github.com/postcss/postcss/commit/777c55b5d2a10605313a4972888f4f32005f5ac2
  8. *
  9. * @namespace vendor
  10. */
  11. const vendor = {
  12. /**
  13. * Returns the vendor prefix extracted from an input string.
  14. *
  15. * @param {string} prop String with or without vendor prefix.
  16. *
  17. * @returns {string} vendor prefix or empty string
  18. *
  19. * @example
  20. * vendor.prefix('-moz-tab-size') //=> '-moz-'
  21. * vendor.prefix('tab-size') //=> ''
  22. */
  23. prefix(prop) {
  24. const match = prop.match(/^(-\w+-)/);
  25. if (match) {
  26. return match[0] || '';
  27. }
  28. return '';
  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. * @returns {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. module.exports = vendor;