Skip to content

Commit 51b991c

Browse files
committed
Improve handling print-color-adjust
1 parent 08d960e commit 51b991c

File tree

7 files changed

+40
-22
lines changed

7 files changed

+40
-22
lines changed

data/prefixes.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,16 +1077,6 @@ f(prefixOverscroll, { match: /a #1/ }, browsers =>
10771077
})
10781078
)
10791079

1080-
// color-adjust
1081-
let prefixColorAdjust = require('caniuse-lite/data/features/css-color-adjust')
1082-
1083-
f(prefixColorAdjust, browsers =>
1084-
prefix(['color-adjust'], {
1085-
feature: 'css-color-adjust',
1086-
browsers
1087-
})
1088-
)
1089-
10901080
// text-orientation
10911081
let prefixTextOrientation = require('caniuse-lite/data/features/css-text-orientation')
10921082

@@ -1096,3 +1086,13 @@ f(prefixTextOrientation, browsers =>
10961086
browsers
10971087
})
10981088
)
1089+
1090+
// print-color-adjust
1091+
let prefixPrintAdjust = require('caniuse-lite/data/features/css-print-color-adjust')
1092+
1093+
f(prefixPrintAdjust, browsers =>
1094+
prefix(['print-color-adjust', 'color-adjust'], {
1095+
feature: 'css-print-color-adjust',
1096+
browsers
1097+
})
1098+
)
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
let Declaration = require('../declaration')
22

3-
class ColorAdjust extends Declaration {
3+
class PrintColorAdjust extends Declaration {
44
/**
55
* Change property name for WebKit-based browsers
66
*/
@@ -12,10 +12,10 @@ class ColorAdjust extends Declaration {
1212
* Return property name by spec
1313
*/
1414
normalize() {
15-
return 'color-adjust'
15+
return 'print-color-adjust'
1616
}
1717
}
1818

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

21-
module.exports = ColorAdjust
21+
module.exports = PrintColorAdjust

lib/prefixes.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ let hackAlignItems = require('./hacks/align-items')
3333
let hackUserSelect = require('./hacks/user-select')
3434
let hackFlexShrink = require('./hacks/flex-shrink')
3535
let hackBreakProps = require('./hacks/break-props')
36-
let hackColorAdjust = require('./hacks/color-adjust')
3736
let hackWritingMode = require('./hacks/writing-mode')
3837
let hackBorderImage = require('./hacks/border-image')
3938
let hackAlignContent = require('./hacks/align-content')
@@ -53,6 +52,7 @@ let hackBackgroundSize = require('./hacks/background-size')
5352
let hackGridRowColumn = require('./hacks/grid-row-column')
5453
let hackGridRowsColumns = require('./hacks/grid-rows-columns')
5554
let hackGridColumnAlign = require('./hacks/grid-column-align')
55+
let hackPrintColorAdjust = require('./hacks/print-color-adjust')
5656
let hackOverscrollBehavior = require('./hacks/overscroll-behavior')
5757
let hackGridTemplateAreas = require('./hacks/grid-template-areas')
5858
let hackTextEmphasisPosition = require('./hacks/text-emphasis-position')
@@ -92,7 +92,6 @@ Declaration.hack(hackAlignItems)
9292
Declaration.hack(hackUserSelect)
9393
Declaration.hack(hackFlexShrink)
9494
Declaration.hack(hackBreakProps)
95-
Declaration.hack(hackColorAdjust)
9695
Declaration.hack(hackWritingMode)
9796
Declaration.hack(hackBorderImage)
9897
Declaration.hack(hackAlignContent)
@@ -114,6 +113,7 @@ Declaration.hack(hackGridRowsColumns)
114113
Declaration.hack(hackGridColumnAlign)
115114
Declaration.hack(hackOverscrollBehavior)
116115
Declaration.hack(hackGridTemplateAreas)
116+
Declaration.hack(hackPrintColorAdjust)
117117
Declaration.hack(hackTextEmphasisPosition)
118118
Declaration.hack(hackTextDecorationSkipInk)
119119
Value.hack(hackGradient)

lib/processor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,13 @@ class Processor {
112112
let prop = decl.prop
113113
let value = decl.value
114114

115-
if (prop === 'grid-row-span') {
115+
if (prop === 'color-adjust') {
116+
result.warn(
117+
'Replace color-adjust to print-color-adjust. ' +
118+
'The color-adjust shorthand is currently deprecated.',
119+
{ node: decl }
120+
)
121+
} else if (prop === 'grid-row-span') {
116122
result.warn(
117123
'grid-row-span is not part of final Grid Layout. Use grid-row.',
118124
{ node: decl }

test/autoprefixer.test.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ const COMMONS = [
243243
'grid-template',
244244
'grid-template-areas',
245245
'grid-gap',
246-
'color-adjust'
246+
'print-color-adjust'
247247
]
248248

249249
test.after.each(() => {
@@ -819,8 +819,20 @@ test('supports overscroll-behavior', () => {
819819
check('overscroll-behavior')
820820
})
821821

822-
test('supports color-adjust', () => {
823-
check('color-adjust')
822+
test('supports print-color-adjust', () => {
823+
let input = read('print-color-adjust')
824+
let output = read('print-color-adjust.out')
825+
let result = postcss([prefixer('print-color-adjust')]).process(input)
826+
827+
equal(result.css, output)
828+
equal(
829+
result.warnings().map(i => i.toString()),
830+
[
831+
'autoprefixer: <css input>:2:3: Replace color-adjust ' +
832+
'to print-color-adjust. The color-adjust shorthand ' +
833+
'is currently deprecated.'
834+
]
835+
)
824836
})
825837

826838
test('supports backdrop-filter', () => {

test/cases/color-adjust.css renamed to test/cases/print-color-adjust.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
}
44

55
.b {
6-
color-adjust: exact;
6+
print-color-adjust: exact;
77
}

test/cases/color-adjust.out.css renamed to test/cases/print-color-adjust.out.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
.b {
77
-webkit-print-color-adjust: exact;
8-
color-adjust: exact;
8+
print-color-adjust: exact;
99
}

0 commit comments

Comments
 (0)