place-self.js 830 B

1234567891011121314151617181920212223242526272829303132
  1. let Declaration = require('../declaration')
  2. let utils = require('./grid-utils')
  3. class PlaceSelf extends Declaration {
  4. /**
  5. * Translate place-self to separate -ms- prefixed properties
  6. */
  7. insert(decl, prefix, prefixes) {
  8. if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes)
  9. // prevent doubling of prefixes
  10. if (decl.parent.some(i => i.prop === '-ms-grid-row-align')) {
  11. return undefined
  12. }
  13. let [[first, second]] = utils.parse(decl)
  14. if (second) {
  15. utils.insertDecl(decl, 'grid-row-align', first)
  16. utils.insertDecl(decl, 'grid-column-align', second)
  17. } else {
  18. utils.insertDecl(decl, 'grid-row-align', first)
  19. utils.insertDecl(decl, 'grid-column-align', first)
  20. }
  21. return undefined
  22. }
  23. }
  24. PlaceSelf.names = ['place-self']
  25. module.exports = PlaceSelf