grid-row-column.js 825 B

123456789101112131415161718192021222324252627282930313233
  1. let Declaration = require('../declaration')
  2. let utils = require('./grid-utils')
  3. class GridRowColumn extends Declaration {
  4. /**
  5. * Translate grid-row / grid-column to separate -ms- prefixed properties
  6. */
  7. insert(decl, prefix, prefixes) {
  8. if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes)
  9. let values = utils.parse(decl)
  10. let [start, span] = utils.translate(values, 0, 1)
  11. let hasStartValueSpan = values[0] && values[0].includes('span')
  12. if (hasStartValueSpan) {
  13. span = values[0].join('').replace(/\D/g, '')
  14. }
  15. ;[
  16. [decl.prop, start],
  17. [`${decl.prop}-span`, span]
  18. ].forEach(([prop, value]) => {
  19. utils.insertDecl(decl, prop, value)
  20. })
  21. return undefined
  22. }
  23. }
  24. GridRowColumn.names = ['grid-row', 'grid-column']
  25. module.exports = GridRowColumn