Skip to content

Commit

Permalink
Add overscroll-behavior support
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Feb 23, 2018
1 parent 2e9c500 commit 49eecef
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions data/prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,3 +769,13 @@ f(bidi, { match: /y x/ }, browsers =>
browsers
})
);


// overscroll-behavior selector
const over = require('caniuse-lite/data/features/css-overscroll-behavior.js');
f(over, { match: /a #1/ }, browsers =>
prefix(['overscroll-behavior'], {
feature: 'css-overscroll-behavior',
browsers
})
);
36 changes: 36 additions & 0 deletions lib/hacks/overscroll-behavior.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

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

class OverscrollBehavior extends Declaration {

static names = ['overscroll-behavior', 'scroll-chaining'];

/**
* Change property name for IE
*/
prefixed(prop, prefix) {
return prefix + 'scroll-chaining';
}

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

/**
* Change value for IE
*/
set(decl, prefix) {
if (decl.value === 'auto') {
decl.value = 'chained';
} else if (decl.value === 'none' || decl.value === 'contain') {
decl.value = 'none';
}
return super.set(decl, prefix);
}

}

module.exports = OverscrollBehavior;
1 change: 1 addition & 0 deletions lib/prefixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Declaration.hack(require('./hacks/background-size'));
Declaration.hack(require('./hacks/grid-row-column'));
Declaration.hack(require('./hacks/grid-rows-columns'));
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'));

Expand Down
6 changes: 6 additions & 0 deletions test/autoprefixer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ const backgrounder = autoprefixer({
const resolutioner = autoprefixer({
browsers: ['Safari 7', 'Opera 12']
});
const overscroller = autoprefixer({
browsers: ['Edge 16']
});

function prefixer(name) {
if (
Expand Down Expand Up @@ -112,6 +115,8 @@ function prefixer(name) {
return intrinsicer;
} else if (name === 'supports') {
return supporter;
} else if (name === 'overscroll-behavior') {
return overscroller;
} else {
return compiler;
}
Expand Down Expand Up @@ -415,6 +420,7 @@ describe('hacks', () => {
it('supports cross-fade()', () => test('cross-fade'));
it('supports text-decoration', () => test('text-decoration'));
it('ignores modern direction', () => test('animation'));
it('supports overscroll-behavior', () => test('overscroll-behavior'));

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

.contain {
overscroll-behavior: contain;
}

.auto {
overscroll-behavior: auto;
}

.inherit {
overscroll-behavior: inherit;
}
19 changes: 19 additions & 0 deletions test/cases/overscroll-behavior.out.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.none {
-ms-scroll-chaining: none;
overscroll-behavior: none;
}

.contain {
-ms-scroll-chaining: none;
overscroll-behavior: contain;
}

.auto {
-ms-scroll-chaining: chained;
overscroll-behavior: auto;
}

.inherit {
-ms-scroll-chaining: inherit;
overscroll-behavior: inherit;
}

0 comments on commit 49eecef

Please sign in to comment.