mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: client: polifyll: migrate to ESM
This commit is contained in:
parent
5b704d0684
commit
9d6cffafdc
4 changed files with 22 additions and 30 deletions
|
|
@ -213,4 +213,3 @@ export async function isChanged() {
|
|||
|
||||
!cancel && await applyNames();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
require('domtokenlist-shim');
|
||||
|
||||
const _scrollIntoViewIfNeeded = require('scroll-into-view-if-needed');
|
||||
import _scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
|
||||
|
||||
globalThis.DOM = globalThis.DOM || {};
|
||||
|
||||
const scrollIntoViewIfNeeded = (el, overrides = {}) => {
|
||||
export const scrollIntoViewIfNeeded = (el, overrides = {}) => {
|
||||
const {
|
||||
scroll = _scrollIntoViewIfNeeded,
|
||||
} = overrides;
|
||||
|
|
@ -17,4 +13,3 @@ const scrollIntoViewIfNeeded = (el, overrides = {}) => {
|
|||
};
|
||||
|
||||
globalThis.DOM.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
|
||||
module.exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const {test, stub} = require('supertape');
|
||||
const {scrollIntoViewIfNeeded} = require('./polyfill');
|
||||
|
||||
test('cloudcmd: client: polyfill: scrollIntoViewIfNeaded', (t) => {
|
||||
const scroll = stub();
|
||||
const el = {};
|
||||
|
||||
scrollIntoViewIfNeeded(el, {
|
||||
scroll,
|
||||
});
|
||||
|
||||
const args = [
|
||||
el, {
|
||||
block: 'nearest',
|
||||
},
|
||||
];
|
||||
|
||||
t.calledWith(scroll, args, 'should call scrollIntoViewIfNeaded');
|
||||
t.end();
|
||||
});
|
||||
20
client/modules/polyfill.spec.mjs
Normal file
20
client/modules/polyfill.spec.mjs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import {test, stub} from 'supertape';
|
||||
import {scrollIntoViewIfNeeded} from './polyfill.mjs';
|
||||
|
||||
test('cloudcmd: client: polyfill: scrollIntoViewIfNeeded', (t) => {
|
||||
const scroll = stub();
|
||||
const el = {};
|
||||
|
||||
scrollIntoViewIfNeeded(el, {
|
||||
scroll,
|
||||
});
|
||||
|
||||
const args = [
|
||||
el, {
|
||||
block: 'nearest',
|
||||
},
|
||||
];
|
||||
|
||||
t.calledWith(scroll, args, 'should call scrollIntoViewIfNeeded');
|
||||
t.end();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue