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

33 lines
830 B
JavaScript
Raw Normal View History

2023-08-17 09:47:40 +00:00
let Declaration = require('../declaration')
let utils = require('./grid-utils')
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
class PlaceSelf extends Declaration {
2022-01-21 08:28:41 +00:00
/**
* Translate place-self to separate -ms- prefixed properties
*/
2023-08-17 09:47:40 +00:00
insert(decl, prefix, prefixes) {
if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes)
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
// prevent doubling of prefixes
if (decl.parent.some(i => i.prop === '-ms-grid-row-align')) {
return undefined
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
let [[first, second]] = utils.parse(decl)
2022-01-21 08:28:41 +00:00
if (second) {
2023-08-17 09:47:40 +00:00
utils.insertDecl(decl, 'grid-row-align', first)
utils.insertDecl(decl, 'grid-column-align', second)
2022-01-21 08:28:41 +00:00
} else {
2023-08-17 09:47:40 +00:00
utils.insertDecl(decl, 'grid-row-align', first)
utils.insertDecl(decl, 'grid-column-align', first)
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
PlaceSelf.names = ['place-self']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = PlaceSelf