Skip to content

Commit 9d6cffa

Browse files
committed
feature: client: polifyll: migrate to ESM
1 parent 5b704d0 commit 9d6cffa

4 files changed

Lines changed: 22 additions & 30 deletions

File tree

client/modules/edit-names.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,3 @@ export async function isChanged() {
213213

214214
!cancel && await applyNames();
215215
}
216-
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
'use strict';
2-
3-
require('domtokenlist-shim');
4-
5-
const _scrollIntoViewIfNeeded = require('scroll-into-view-if-needed');
1+
import _scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';
62

73
globalThis.DOM = globalThis.DOM || {};
84

9-
const scrollIntoViewIfNeeded = (el, overrides = {}) => {
5+
export const scrollIntoViewIfNeeded = (el, overrides = {}) => {
106
const {
117
scroll = _scrollIntoViewIfNeeded,
128
} = overrides;
@@ -17,4 +13,3 @@ const scrollIntoViewIfNeeded = (el, overrides = {}) => {
1713
};
1814

1915
globalThis.DOM.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;
20-
module.exports.scrollIntoViewIfNeeded = scrollIntoViewIfNeeded;

client/modules/polyfill.spec.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

client/modules/polyfill.spec.mjs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {test, stub} from 'supertape';
2+
import {scrollIntoViewIfNeeded} from './polyfill.mjs';
3+
4+
test('cloudcmd: client: polyfill: scrollIntoViewIfNeeded', (t) => {
5+
const scroll = stub();
6+
const el = {};
7+
8+
scrollIntoViewIfNeeded(el, {
9+
scroll,
10+
});
11+
12+
const args = [
13+
el, {
14+
block: 'nearest',
15+
},
16+
];
17+
18+
t.calledWith(scroll, args, 'should call scrollIntoViewIfNeeded');
19+
t.end();
20+
});

0 commit comments

Comments
 (0)