wishthis/node_modules/autoprefixer/lib/hacks/grid-row-column.js

34 lines
825 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 GridRowColumn extends Declaration {
2022-01-21 08:28:41 +00:00
/**
* Translate grid-row / grid-column 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
let values = utils.parse(decl)
let [start, span] = utils.translate(values, 0, 1)
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
let hasStartValueSpan = values[0] && values[0].includes('span')
2022-01-21 08:28:41 +00:00
if (hasStartValueSpan) {
2023-08-17 09:47:40 +00:00
span = values[0].join('').replace(/\D/g, '')
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
;[
[decl.prop, start],
[`${decl.prop}-span`, span]
].forEach(([prop, value]) => {
utils.insertDecl(decl, prop, value)
})
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
GridRowColumn.names = ['grid-row', 'grid-column']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = GridRowColumn