block-logical.js 857 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. let Declaration = require('../declaration')
  2. class BlockLogical extends Declaration {
  3. /**
  4. * Use old syntax for -moz- and -webkit-
  5. */
  6. prefixed(prop, prefix) {
  7. if (prop.includes('-start')) {
  8. return prefix + prop.replace('-block-start', '-before')
  9. }
  10. return prefix + prop.replace('-block-end', '-after')
  11. }
  12. /**
  13. * Return property name by spec
  14. */
  15. normalize(prop) {
  16. if (prop.includes('-before')) {
  17. return prop.replace('-before', '-block-start')
  18. }
  19. return prop.replace('-after', '-block-end')
  20. }
  21. }
  22. BlockLogical.names = [
  23. 'border-block-start',
  24. 'border-block-end',
  25. 'margin-block-start',
  26. 'margin-block-end',
  27. 'padding-block-start',
  28. 'padding-block-end',
  29. 'border-before',
  30. 'border-after',
  31. 'margin-before',
  32. 'margin-after',
  33. 'padding-before',
  34. 'padding-after'
  35. ]
  36. module.exports = BlockLogical