fix(test): use bare matchMedia() instead of window.matchMedia() for Node ESM compat
global.window assignment doesn't expose 'window' as an identifier in ESM modules in Node.js 22. matchMedia() is a global in browsers - no window. prefix needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -536,7 +536,7 @@ export function validateAll(formContainer) {
|
||||
export function btnSuccess(btn, originalLabel) {
|
||||
const label = originalLabel ?? btn.textContent;
|
||||
btn.classList.add('btn--success');
|
||||
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
if (!reducedMotion) {
|
||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
svg.setAttribute('width', '16');
|
||||
@@ -579,7 +579,7 @@ export function btnLoading(btn) {
|
||||
* @param {HTMLButtonElement} btn
|
||||
*/
|
||||
export function btnError(btn) {
|
||||
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
if (matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||
btn.classList.add('btn--error-static');
|
||||
setTimeout(() => btn.classList.remove('btn--error-static'), 700);
|
||||
return;
|
||||
|
||||
+2
-2
@@ -10,8 +10,8 @@ import assert from 'node:assert/strict';
|
||||
// /i18n.js wird durch test-browser-loader.mjs gemockt (--loader Flag)
|
||||
const { wireBlurValidation, btnSuccess, btnError } = await import('./public/components/modal.js');
|
||||
|
||||
// window.matchMedia und document.createElementNS werden von btnSuccess/btnError benötigt
|
||||
global.window = { matchMedia: () => ({ matches: false }) };
|
||||
// matchMedia und document.createElementNS werden von btnSuccess/btnError benötigt
|
||||
global.matchMedia = () => ({ matches: false });
|
||||
|
||||
const _makeSvgEl = (tag) => {
|
||||
const attrs = {};
|
||||
|
||||
Reference in New Issue
Block a user