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) {
|
export function btnSuccess(btn, originalLabel) {
|
||||||
const label = originalLabel ?? btn.textContent;
|
const label = originalLabel ?? btn.textContent;
|
||||||
btn.classList.add('btn--success');
|
btn.classList.add('btn--success');
|
||||||
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
const reducedMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||||
if (!reducedMotion) {
|
if (!reducedMotion) {
|
||||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||||
svg.setAttribute('width', '16');
|
svg.setAttribute('width', '16');
|
||||||
@@ -579,7 +579,7 @@ export function btnLoading(btn) {
|
|||||||
* @param {HTMLButtonElement} btn
|
* @param {HTMLButtonElement} btn
|
||||||
*/
|
*/
|
||||||
export function btnError(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');
|
btn.classList.add('btn--error-static');
|
||||||
setTimeout(() => btn.classList.remove('btn--error-static'), 700);
|
setTimeout(() => btn.classList.remove('btn--error-static'), 700);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-2
@@ -10,8 +10,8 @@ import assert from 'node:assert/strict';
|
|||||||
// /i18n.js wird durch test-browser-loader.mjs gemockt (--loader Flag)
|
// /i18n.js wird durch test-browser-loader.mjs gemockt (--loader Flag)
|
||||||
const { wireBlurValidation, btnSuccess, btnError } = await import('./public/components/modal.js');
|
const { wireBlurValidation, btnSuccess, btnError } = await import('./public/components/modal.js');
|
||||||
|
|
||||||
// window.matchMedia und document.createElementNS werden von btnSuccess/btnError benötigt
|
// matchMedia und document.createElementNS werden von btnSuccess/btnError benötigt
|
||||||
global.window = { matchMedia: () => ({ matches: false }) };
|
global.matchMedia = () => ({ matches: false });
|
||||||
|
|
||||||
const _makeSvgEl = (tag) => {
|
const _makeSvgEl = (tag) => {
|
||||||
const attrs = {};
|
const attrs = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user