border-radius.js 907 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. let Declaration = require('../declaration')
  2. class BorderRadius extends Declaration {
  3. /**
  4. * Change syntax, when add Mozilla prefix
  5. */
  6. prefixed(prop, prefix) {
  7. if (prefix === '-moz-') {
  8. return prefix + (BorderRadius.toMozilla[prop] || prop)
  9. }
  10. return super.prefixed(prop, prefix)
  11. }
  12. /**
  13. * Return unprefixed version of property
  14. */
  15. normalize(prop) {
  16. return BorderRadius.toNormal[prop] || prop
  17. }
  18. }
  19. BorderRadius.names = ['border-radius']
  20. BorderRadius.toMozilla = {}
  21. BorderRadius.toNormal = {}
  22. for (let ver of ['top', 'bottom']) {
  23. for (let hor of ['left', 'right']) {
  24. let normal = `border-${ver}-${hor}-radius`
  25. let mozilla = `border-radius-${ver}${hor}`
  26. BorderRadius.names.push(normal)
  27. BorderRadius.names.push(mozilla)
  28. BorderRadius.toMozilla[normal] = mozilla
  29. BorderRadius.toNormal[mozilla] = normal
  30. }
  31. }
  32. module.exports = BorderRadius