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