wishthis/node_modules/autoprefixer/lib/hacks/border-radius.js

41 lines
907 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 BorderRadius extends Declaration {
/**
* Return unprefixed version of property
*/
normalize(prop) {
return BorderRadius.toNormal[prop] || prop
2022-01-21 08:28:41 +00:00
}
/**
* Change syntax, when add Mozilla prefix
*/
2023-08-17 09:47:40 +00:00
prefixed(prop, prefix) {
2022-01-21 08:28:41 +00:00
if (prefix === '-moz-') {
2023-08-17 09:47:40 +00:00
return prefix + (BorderRadius.toMozilla[prop] || prop)
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
2023-08-17 09:47:40 +00:00
BorderRadius.names = ['border-radius']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
BorderRadius.toMozilla = {}
BorderRadius.toNormal = {}
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
for (let ver of ['top', 'bottom']) {
for (let hor of ['left', 'right']) {
let normal = `border-${ver}-${hor}-radius`
let mozilla = `border-radius-${ver}${hor}`
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
BorderRadius.names.push(normal)
BorderRadius.names.push(mozilla)
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
BorderRadius.toMozilla[normal] = mozilla
BorderRadius.toNormal[mozilla] = normal
2022-01-21 08:28:41 +00:00
}
}
2023-08-17 09:47:40 +00:00
module.exports = BorderRadius