align-items.js 968 B

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