mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(polyfill) scrollIntoViewIfNeeded in firefox
This commit is contained in:
parent
6957a876e8
commit
619e0828af
2 changed files with 35 additions and 1 deletions
|
|
@ -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'
|
||||
});
|
||||
|
||||
|
|
|
|||
32
client/modules/polyfill.spec.js
Normal file
32
client/modules/polyfill.spec.js
Normal 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();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue