wishthis/node_modules/autoprefixer/lib/hacks/flex-shrink.js

40 lines
801 B
JavaScript
Raw Normal View History

2023-08-17 09:47:40 +00:00
let flexSpec = require('./flex-spec')
let Declaration = require('../declaration')
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
class FlexShrink extends Declaration {
2022-01-21 08:28:41 +00:00
/**
* Return property name by final spec
*/
2023-08-17 09:47:40 +00:00
normalize() {
return 'flex-shrink'
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
2022-01-21 08:28:41 +00:00
/**
* Return flex property for 2012 spec
*/
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-negative'
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
}
2023-08-17 09:47:40 +00:00
2022-01-21 08:28:41 +00:00
/**
* Ignore 2009 spec and use flex property for 2012
*/
2023-08-17 09:47:40 +00:00
set(decl, prefix) {
let spec
;[spec, prefix] = flexSpec(prefix)
2022-01-21 08:28:41 +00:00
if (spec === 2012 || 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
FlexShrink.names = ['flex-shrink', 'flex-negative']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = FlexShrink