wishthis/node_modules/autoprefixer/lib/hacks/align-self.js

57 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-08-17 09:47:40 +00:00
let flexSpec = require('./flex-spec')
let Declaration = require('../declaration')
class AlignSelf extends Declaration {
check(decl) {
return (
decl.parent &&
!decl.parent.some(i => {
return i.prop && i.prop.startsWith('grid-')
})
)
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
/**
* Return property name by final spec
*/
normalize() {
return 'align-self'
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
2022-01-21 08:28:41 +00:00
/**
* Change property name for 2012 specs
*/
2023-08-17 09:47:40 +00:00
prefixed(prop, prefix) {
let spec
;[spec, prefix] = flexSpec(prefix)
2022-01-21 08:28:41 +00:00
if (spec === 2012) {
2023-08-17 09:47:40 +00:00
return prefix + 'flex-item-align'
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return super.prefixed(prop, prefix)
2022-01-21 08:28:41 +00:00
}
/**
* Change value for 2012 spec and ignore prefix for 2009
*/
2023-08-17 09:47:40 +00:00
set(decl, prefix) {
let spec = flexSpec(prefix)[0]
2022-01-21 08:28:41 +00:00
if (spec === 2012) {
2023-08-17 09:47:40 +00:00
decl.value = AlignSelf.oldValues[decl.value] || decl.value
return super.set(decl, prefix)
2022-01-21 08:28:41 +00:00
}
if (spec === 'final') {
2023-08-17 09:47:40 +00:00
return super.set(decl, prefix)
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return undefined
}
}
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
AlignSelf.names = ['align-self', 'flex-item-align']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
AlignSelf.oldValues = {
2022-01-21 08:28:41 +00:00
'flex-end': 'end',
'flex-start': 'start'
2023-08-17 09:47:40 +00:00
}
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = AlignSelf