| 1 |
let Declaration = require('../declaration') |
| 2 |
let flexSpec = require('./flex-spec') |
| 3 |
|
| 4 |
class JustifyContent extends Declaration { |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
normalize() { |
| 9 |
return 'justify-content' |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
prefixed(prop, prefix) { |
| 16 |
let spec |
| 17 |
;[spec, prefix] = flexSpec(prefix) |
| 18 |
if (spec === 2009) { |
| 19 |
return prefix + 'box-pack' |
| 20 |
} |
| 21 |
if (spec === 2012) { |
| 22 |
return prefix + 'flex-pack' |
| 23 |
} |
| 24 |
return super.prefixed(prop, prefix) |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
set(decl, prefix) { |
| 31 |
let spec = flexSpec(prefix)[0] |
| 32 |
if (spec === 2009 || spec === 2012) { |
| 33 |
let value = JustifyContent.oldValues[decl.value] || decl.value |
| 34 |
decl.value = value |
| 35 |
if (spec !== 2009 || value !== 'distribute') { |
| 36 |
return super.set(decl, prefix) |
| 37 |
} |
| 38 |
} else if (spec === 'final') { |
| 39 |
return super.set(decl, prefix) |
| 40 |
} |
| 41 |
return undefined |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
JustifyContent.names = ['justify-content', 'flex-pack', 'box-pack'] |
| 46 |
|
| 47 |
JustifyContent.oldValues = { |
| 48 |
'flex-end': 'end', |
| 49 |
'flex-start': 'start', |
| 50 |
'space-around': 'distribute', |
| 51 |
'space-between': 'justify' |
| 52 |
} |
| 53 |
|
| 54 |
module.exports = JustifyContent |