Skip to content

Commit

Permalink
[color-adjust]: added support for color-adjust declarations (#1007)
Browse files Browse the repository at this point in the history
* wip: added hack and test, awaiting for caniuse PR

* test(autprefixer): added `color-adjust` property to COMMONS
  • Loading branch information
YozhikM authored and ai committed Mar 21, 2018
1 parent 6579eb5 commit cbf41b9
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
8 changes: 8 additions & 0 deletions data/prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,11 @@ f(over, { match: /a #1/ }, browsers =>
browsers
})
);

// color-adjust
f(require('caniuse-lite/data/features/css-color-adjust.js'), browsers =>
prefix(['color-adjust'], {
feature: 'css-color-adjust',
browsers
})
);
23 changes: 23 additions & 0 deletions lib/hacks/color-adjust.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

const Declaration = require('../declaration');

class ColorAdjust extends Declaration {

static names = ['color-adjust'];

/**
* Change property name for -webkit browsers
*/
prefixed(prop, prefix) {
return prefix + 'print-color-adjust';
}

/**
* Return property name by spec
*/
normalize() {
return 'color-adjust';
}
}

module.exports = ColorAdjust;
1 change: 1 addition & 0 deletions lib/prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Declaration.hack(require('./hacks/grid-column-align'));
Declaration.hack(require('./hacks/overscroll-behavior'));
Declaration.hack(require('./hacks/grid-template-areas'));
Declaration.hack(require('./hacks/text-emphasis-position'));
Declaration.hack(require('./hacks/color-adjust'));

Value.hack(require('./hacks/gradient'));
Value.hack(require('./hacks/intrinsic'));
Expand Down
3 changes: 2 additions & 1 deletion test/autoprefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const COMMONS = [
'advanced-filter', 'element', 'image-set', 'image-rendering',
'mask-border', 'writing-mode', 'cross-fade', 'gradient-fix',
'text-emphasis-position', 'grid', 'grid-area', 'grid-template',
'grid-template-areas'
'grid-template-areas', 'color-adjust'
];

it('throws on wrong options', () => {
Expand Down Expand Up @@ -422,6 +422,7 @@ describe('hacks', () => {
it('supports text-decoration', () => test('text-decoration'));
it('ignores modern direction', () => test('animation'));
it('supports overscroll-behavior', () => test('overscroll-behavior'));
it('supports color-adjust', () => test('color-adjust'));

it('supports appearance for IE', () => {
const instance = autoprefixer({ browsers: 'Edge 15' });
Expand Down
7 changes: 7 additions & 0 deletions test/cases/color-adjust.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.economy {
color-adjsut: economy;
}

.exact {
color-adjsut: exact;
}
9 changes: 9 additions & 0 deletions test/cases/color-adjust.out.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.economy {
-webkit-print-color-adjust: economy;
color-adjsut: economy;
}

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

0 comments on commit cbf41b9

Please sign in to comment.