fix(polyfill) scrollIntoViewIfNeeded in firefox

This commit is contained in:
coderaiser 2018-07-16 16:07:04 +03:00
parent 6957a876e8
commit 619e0828af
2 changed files with 35 additions and 1 deletions

View file

@ -5,5 +5,7 @@
require('domtokenlist-shim');
const scrollIntoViewIfNeeded = require('scroll-into-view-if-needed').default;
DOM.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
DOM.scrollIntoViewIfNeeded = (el) => scrollIntoViewIfNeeded(el, {
block: 'nearest'
});

View file

@ -0,0 +1,32 @@
'use stric';
const test = require('tape');
const mockRequire = require('mock-require');
const diff = require('sinon-called-with-diff');
const sinon = diff(require('sinon'));
test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
const {DOM} = global;
const scroll = sinon.stub();
const el = {};
global.DOM = {};
mockRequire('scroll-into-view-if-needed', {
default: scroll
});
mockRequire.reRequire('./polyfill');
global.DOM.scrollIntoViewIfNeeded(el);
mockRequire.stop('scroll-into-view-if-neaded');
global.DOM = DOM;
const args = [
el, {
block: 'nearest',
}];
t.ok(scroll.calledWith(...args), 'should call scrollIntoViewIfNeaded');
t.end();
});