wishthis/node_modules/autoprefixer/lib/hacks/block-logical.js

41 lines
857 B
JavaScript
Raw Normal View History

2023-08-17 09:47:40 +00:00
let Declaration = require('../declaration')
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
class BlockLogical extends Declaration {
/**
* Return property name by spec
*/
normalize(prop) {
if (prop.includes('-before')) {
return prop.replace('-before', '-block-start')
}
return prop.replace('-after', '-block-end')
2022-01-21 08:28:41 +00:00
}
/**
* Use old syntax for -moz- and -webkit-
*/
2023-08-17 09:47:40 +00:00
prefixed(prop, prefix) {
2022-01-21 08:28:41 +00:00
if (prop.includes('-start')) {
2023-08-17 09:47:40 +00:00
return prefix + prop.replace('-block-start', '-before')
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return prefix + prop.replace('-block-end', '-after')
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
}
BlockLogical.names = [
'border-block-start',
'border-block-end',
'margin-block-start',
'margin-block-end',
'padding-block-start',
'padding-block-end',
'border-before',
'border-after',
'margin-before',
'margin-after',
'padding-before',
'padding-after'
]
module.exports = BlockLogical