align-content.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. let flexSpec = require('./flex-spec')
  2. let Declaration = require('../declaration')
  3. class AlignContent extends Declaration {
  4. /**
  5. * Change property name for 2012 spec
  6. */
  7. prefixed(prop, prefix) {
  8. let spec
  9. ;[spec, prefix] = flexSpec(prefix)
  10. if (spec === 2012) {
  11. return prefix + 'flex-line-pack'
  12. }
  13. return super.prefixed(prop, prefix)
  14. }
  15. /**
  16. * Return property name by final spec
  17. */
  18. normalize() {
  19. return 'align-content'
  20. }
  21. /**
  22. * Change value for 2012 spec and ignore prefix for 2009
  23. */
  24. set(decl, prefix) {
  25. let spec = flexSpec(prefix)[0]
  26. if (spec === 2012) {
  27. decl.value = AlignContent.oldValues[decl.value] || decl.value
  28. return super.set(decl, prefix)
  29. }
  30. if (spec === 'final') {
  31. return super.set(decl, prefix)
  32. }
  33. return undefined
  34. }
  35. }
  36. AlignContent.names = ['align-content', 'flex-line-pack']
  37. AlignContent.oldValues = {
  38. 'flex-end': 'end',
  39. 'flex-start': 'start',
  40. 'space-between': 'justify',
  41. 'space-around': 'distribute'
  42. }
  43. module.exports = AlignContent