feature: client: polifyll: migrate to ESM

This commit is contained in:
coderiaser 2026-02-03 13:27:16 +02:00
parent 5b704d0684
commit 9d6cffafdc
4 changed files with 22 additions and 30 deletions

View file

@ -213,4 +213,3 @@ export async function isChanged() {
!cancel && await applyNames();
}

View file

@ -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;

View file

@ -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();
});

View 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();
});