wishthis/node_modules/autoprefixer/lib/hacks/pixelated.js

35 lines
819 B
JavaScript
Raw Normal View History

2023-08-17 09:47:40 +00:00
let OldValue = require('../old-value')
let Value = require('../value')
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
class Pixelated extends Value {
2022-01-21 08:28:41 +00:00
/**
2023-08-17 09:47:40 +00:00
* Different name for WebKit and Firefox
2022-01-21 08:28:41 +00:00
*/
2023-08-17 09:47:40 +00:00
old(prefix) {
2022-01-21 08:28:41 +00:00
if (prefix === '-webkit-') {
2023-08-17 09:47:40 +00:00
return new OldValue(this.name, '-webkit-optimize-contrast')
2022-01-21 08:28:41 +00:00
}
if (prefix === '-moz-') {
2023-08-17 09:47:40 +00:00
return new OldValue(this.name, '-moz-crisp-edges')
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return super.old(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
* Use non-standard name for WebKit and Firefox
2022-01-21 08:28:41 +00:00
*/
2023-08-17 09:47:40 +00:00
replace(string, prefix) {
2022-01-21 08:28:41 +00:00
if (prefix === '-webkit-') {
2023-08-17 09:47:40 +00:00
return string.replace(this.regexp(), '$1-webkit-optimize-contrast')
2022-01-21 08:28:41 +00:00
}
if (prefix === '-moz-') {
2023-08-17 09:47:40 +00:00
return string.replace(this.regexp(), '$1-moz-crisp-edges')
2022-01-21 08:28:41 +00:00
}
2023-08-17 09:47:40 +00:00
return super.replace(string, prefix)
}
}
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
Pixelated.names = ['pixelated']
2022-01-21 08:28:41 +00:00
2023-08-17 09:47:40 +00:00
module.exports = Pixelated