Skip to content

Commit

Permalink
Improve handling print-color-adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed May 1, 2022
1 parent 08d960e commit 51b991c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
20 changes: 10 additions & 10 deletions data/prefixes.js
Expand Up @@ -1077,16 +1077,6 @@ f(prefixOverscroll, { match: /a #1/ }, browsers =>
})
)

// color-adjust
let prefixColorAdjust = require('caniuse-lite/data/features/css-color-adjust')

f(prefixColorAdjust, browsers =>
prefix(['color-adjust'], {
feature: 'css-color-adjust',
browsers
})
)

// text-orientation
let prefixTextOrientation = require('caniuse-lite/data/features/css-text-orientation')

Expand All @@ -1096,3 +1086,13 @@ f(prefixTextOrientation, browsers =>
browsers
})
)

// print-color-adjust
let prefixPrintAdjust = require('caniuse-lite/data/features/css-print-color-adjust')

f(prefixPrintAdjust, browsers =>
prefix(['print-color-adjust', 'color-adjust'], {
feature: 'css-print-color-adjust',
browsers
})
)
8 changes: 4 additions & 4 deletions lib/hacks/color-adjust.js → lib/hacks/print-color-adjust.js
@@ -1,6 +1,6 @@
let Declaration = require('../declaration')

class ColorAdjust extends Declaration {
class PrintColorAdjust extends Declaration {
/**
* Change property name for WebKit-based browsers
*/
Expand All @@ -12,10 +12,10 @@ class ColorAdjust extends Declaration {
* Return property name by spec
*/
normalize() {
return 'color-adjust'
return 'print-color-adjust'
}
}

ColorAdjust.names = ['color-adjust', 'print-color-adjust']
PrintColorAdjust.names = ['print-color-adjust', 'color-adjust']

module.exports = ColorAdjust
module.exports = PrintColorAdjust
4 changes: 2 additions & 2 deletions lib/prefixes.js
Expand Up @@ -33,7 +33,6 @@ let hackAlignItems = require('./hacks/align-items')
let hackUserSelect = require('./hacks/user-select')
let hackFlexShrink = require('./hacks/flex-shrink')
let hackBreakProps = require('./hacks/break-props')
let hackColorAdjust = require('./hacks/color-adjust')
let hackWritingMode = require('./hacks/writing-mode')
let hackBorderImage = require('./hacks/border-image')
let hackAlignContent = require('./hacks/align-content')
Expand All @@ -53,6 +52,7 @@ let hackBackgroundSize = require('./hacks/background-size')
let hackGridRowColumn = require('./hacks/grid-row-column')
let hackGridRowsColumns = require('./hacks/grid-rows-columns')
let hackGridColumnAlign = require('./hacks/grid-column-align')
let hackPrintColorAdjust = require('./hacks/print-color-adjust')
let hackOverscrollBehavior = require('./hacks/overscroll-behavior')
let hackGridTemplateAreas = require('./hacks/grid-template-areas')
let hackTextEmphasisPosition = require('./hacks/text-emphasis-position')
Expand Down Expand Up @@ -92,7 +92,6 @@ Declaration.hack(hackAlignItems)
Declaration.hack(hackUserSelect)
Declaration.hack(hackFlexShrink)
Declaration.hack(hackBreakProps)
Declaration.hack(hackColorAdjust)
Declaration.hack(hackWritingMode)
Declaration.hack(hackBorderImage)
Declaration.hack(hackAlignContent)
Expand All @@ -114,6 +113,7 @@ Declaration.hack(hackGridRowsColumns)
Declaration.hack(hackGridColumnAlign)
Declaration.hack(hackOverscrollBehavior)
Declaration.hack(hackGridTemplateAreas)
Declaration.hack(hackPrintColorAdjust)
Declaration.hack(hackTextEmphasisPosition)
Declaration.hack(hackTextDecorationSkipInk)
Value.hack(hackGradient)
Expand Down
8 changes: 7 additions & 1 deletion lib/processor.js
Expand Up @@ -112,7 +112,13 @@ class Processor {
let prop = decl.prop
let value = decl.value

if (prop === 'grid-row-span') {
if (prop === 'color-adjust') {
result.warn(
'Replace color-adjust to print-color-adjust. ' +
'The color-adjust shorthand is currently deprecated.',
{ node: decl }
)
} else if (prop === 'grid-row-span') {
result.warn(
'grid-row-span is not part of final Grid Layout. Use grid-row.',
{ node: decl }
Expand Down
18 changes: 15 additions & 3 deletions test/autoprefixer.test.js
Expand Up @@ -243,7 +243,7 @@ const COMMONS = [
'grid-template',
'grid-template-areas',
'grid-gap',
'color-adjust'
'print-color-adjust'
]

test.after.each(() => {
Expand Down Expand Up @@ -819,8 +819,20 @@ test('supports overscroll-behavior', () => {
check('overscroll-behavior')
})

test('supports color-adjust', () => {
check('color-adjust')
test('supports print-color-adjust', () => {
let input = read('print-color-adjust')
let output = read('print-color-adjust.out')
let result = postcss([prefixer('print-color-adjust')]).process(input)

equal(result.css, output)
equal(
result.warnings().map(i => i.toString()),
[
'autoprefixer: <css input>:2:3: Replace color-adjust ' +
'to print-color-adjust. The color-adjust shorthand ' +
'is currently deprecated.'
]
)
})

test('supports backdrop-filter', () => {
Expand Down
Expand Up @@ -3,5 +3,5 @@
}

.b {
color-adjust: exact;
print-color-adjust: exact;
}
Expand Up @@ -5,5 +5,5 @@

.b {
-webkit-print-color-adjust: exact;
color-adjust: exact;
print-color-adjust: exact;
}

0 comments on commit 51b991c

Please sign in to comment.