@schukai/monster 4.77.1 → 4.77.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
 
4
4
 
5
+ ## [4.77.2] - 2026-01-05
6
+
7
+ ### Bug Fixes
8
+
9
+ - cahgen wait time to 10
10
+ ### Changes
11
+
12
+ - update test timeout
13
+
14
+
15
+
5
16
  ## [4.77.1] - 2026-01-05
6
17
 
7
18
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.77.1"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.77.2"}
@@ -16,14 +16,14 @@ import { getGlobal } from "../types/global.mjs";
16
16
  import { validateString } from "../types/validate.mjs";
17
17
 
18
18
  export {
19
- getDocument,
20
- getWindow,
21
- getDocumentFragmentFromString,
22
- findElementWithIdUpwards,
23
- getContainingDocument,
24
- getRegisteredCustomElements,
25
- findElementWithSelectorUpwards,
26
- waitForCustomElement,
19
+ getDocument,
20
+ getWindow,
21
+ getDocumentFragmentFromString,
22
+ findElementWithIdUpwards,
23
+ getContainingDocument,
24
+ getRegisteredCustomElements,
25
+ findElementWithSelectorUpwards,
26
+ waitForCustomElement,
27
27
  };
28
28
 
29
29
  /**
@@ -63,12 +63,12 @@ export {
63
63
  * @throws {Error} not supported environment
64
64
  */
65
65
  function getDocument() {
66
- const document = getGlobal()?.["document"];
67
- if (typeof document !== "object") {
68
- throw new Error("not supported environment");
69
- }
66
+ const document = getGlobal()?.["document"];
67
+ if (typeof document !== "object") {
68
+ throw new Error("not supported environment");
69
+ }
70
70
 
71
- return document;
71
+ return document;
72
72
  }
73
73
 
74
74
  /**
@@ -110,12 +110,12 @@ function getDocument() {
110
110
  * @throws {Error} not supported environment
111
111
  */
112
112
  function getWindow() {
113
- const window = getGlobal()?.["window"];
114
- if (typeof window !== "object") {
115
- throw new Error("not supported environment");
116
- }
113
+ const window = getGlobal()?.["window"];
114
+ if (typeof window !== "object") {
115
+ throw new Error("not supported environment");
116
+ }
117
117
 
118
- return window;
118
+ return window;
119
119
  }
120
120
 
121
121
  /**
@@ -156,13 +156,13 @@ function getWindow() {
156
156
  * @throws {TypeError} value is not a string
157
157
  */
158
158
  function getDocumentFragmentFromString(html) {
159
- validateString(html);
159
+ validateString(html);
160
160
 
161
- const document = getDocument();
162
- const template = document.createElement("template");
163
- template.innerHTML = html;
161
+ const document = getDocument();
162
+ const template = document.createElement("template");
163
+ template.innerHTML = html;
164
164
 
165
- return template.content;
165
+ return template.content;
166
166
  }
167
167
 
168
168
  /**
@@ -177,39 +177,39 @@ function getDocumentFragmentFromString(html) {
177
177
  * @copyright Volker Schukai
178
178
  */
179
179
  function findElementWithIdUpwards(element, targetId) {
180
- if (!element) {
181
- return null;
182
- }
183
-
184
- // Check if the current element has the target ID
185
- if (element.id === targetId) {
186
- return element;
187
- }
188
-
189
- // Search within the current element's shadow root, if it exists
190
- if (element.shadowRoot) {
191
- const target = element.shadowRoot.getElementById(targetId);
192
- if (target) {
193
- return target;
194
- }
195
- }
196
-
197
- // If the current element is the document.documentElement, search within the main document
198
- if (element === document.documentElement || element === document) {
199
- const target = document.getElementById(targetId);
200
- if (target) {
201
- return target;
202
- }
203
- }
204
-
205
- // If the current element is inside a shadow root, search its host's ancestors
206
- const rootNode = element.getRootNode();
207
- if (rootNode && rootNode instanceof ShadowRoot) {
208
- return findElementWithIdUpwards(rootNode.host, targetId);
209
- }
210
-
211
- // Otherwise, search the current element's parent
212
- return findElementWithIdUpwards(element.parentElement, targetId);
180
+ if (!element) {
181
+ return null;
182
+ }
183
+
184
+ // Check if the current element has the target ID
185
+ if (element.id === targetId) {
186
+ return element;
187
+ }
188
+
189
+ // Search within the current element's shadow root, if it exists
190
+ if (element.shadowRoot) {
191
+ const target = element.shadowRoot.getElementById(targetId);
192
+ if (target) {
193
+ return target;
194
+ }
195
+ }
196
+
197
+ // If the current element is the document.documentElement, search within the main document
198
+ if (element === document.documentElement || element === document) {
199
+ const target = document.getElementById(targetId);
200
+ if (target) {
201
+ return target;
202
+ }
203
+ }
204
+
205
+ // If the current element is inside a shadow root, search its host's ancestors
206
+ const rootNode = element.getRootNode();
207
+ if (rootNode && rootNode instanceof ShadowRoot) {
208
+ return findElementWithIdUpwards(rootNode.host, targetId);
209
+ }
210
+
211
+ // Otherwise, search the current element's parent
212
+ return findElementWithIdUpwards(element.parentElement, targetId);
213
213
  }
214
214
 
215
215
  /**
@@ -223,33 +223,33 @@ function findElementWithIdUpwards(element, targetId) {
223
223
  * @since 3.55.0
224
224
  */
225
225
  function findElementWithSelectorUpwards(element, selector) {
226
- if (!element || !selector) {
227
- return null;
228
- }
229
-
230
- // Search within the current element's shadow root, if it exists
231
- if (element.shadowRoot) {
232
- const target = element.shadowRoot.querySelector(selector);
233
- if (target) {
234
- return target;
235
- }
236
- }
237
-
238
- if (element === document.documentElement) {
239
- const target = document.querySelector(selector);
240
- if (target) {
241
- return target;
242
- }
243
- }
244
-
245
- // If the current element is inside a shadow root, search its host's ancestors
246
- const rootNode = element.getRootNode();
247
- if (rootNode && rootNode instanceof ShadowRoot) {
248
- return findElementWithSelectorUpwards(rootNode.host, selector);
249
- }
250
-
251
- // Otherwise, search the current element's parent
252
- return findElementWithSelectorUpwards(element.parentElement, selector);
226
+ if (!element || !selector) {
227
+ return null;
228
+ }
229
+
230
+ // Search within the current element's shadow root, if it exists
231
+ if (element.shadowRoot) {
232
+ const target = element.shadowRoot.querySelector(selector);
233
+ if (target) {
234
+ return target;
235
+ }
236
+ }
237
+
238
+ if (element === document.documentElement) {
239
+ const target = document.querySelector(selector);
240
+ if (target) {
241
+ return target;
242
+ }
243
+ }
244
+
245
+ // If the current element is inside a shadow root, search its host's ancestors
246
+ const rootNode = element.getRootNode();
247
+ if (rootNode && rootNode instanceof ShadowRoot) {
248
+ return findElementWithSelectorUpwards(rootNode.host, selector);
249
+ }
250
+
251
+ // Otherwise, search the current element's parent
252
+ return findElementWithSelectorUpwards(element.parentElement, selector);
253
253
  }
254
254
 
255
255
  /**
@@ -258,34 +258,34 @@ function findElementWithSelectorUpwards(element, selector) {
258
258
  * @return {HTMLElement|null}
259
259
  */
260
260
  function traverseShadowRoots(element) {
261
- let currentRoot = element.shadowRoot;
262
- let currentParent = element.parentNode;
263
-
264
- while (
265
- currentParent &&
266
- currentParent.nodeType !== Node.DOCUMENT_NODE &&
267
- currentParent.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
268
- ) {
269
- if (currentRoot && currentRoot.parentNode) {
270
- currentParent = currentRoot.parentNode;
271
- currentRoot = currentParent.shadowRoot;
272
- } else if (currentParent.parentNode) {
273
- currentParent = currentParent.parentNode;
274
- currentRoot = null;
275
- } else if (
276
- currentRoot &&
277
- currentRoot.host &&
278
- currentRoot.host.nodeType === Node.DOCUMENT_NODE
279
- ) {
280
- currentParent = currentRoot.host;
281
- currentRoot = null;
282
- } else {
283
- currentParent = null;
284
- currentRoot = null;
285
- }
286
- }
287
-
288
- return currentParent;
261
+ let currentRoot = element.shadowRoot;
262
+ let currentParent = element.parentNode;
263
+
264
+ while (
265
+ currentParent &&
266
+ currentParent.nodeType !== Node.DOCUMENT_NODE &&
267
+ currentParent.nodeType !== Node.DOCUMENT_FRAGMENT_NODE
268
+ ) {
269
+ if (currentRoot && currentRoot.parentNode) {
270
+ currentParent = currentRoot.parentNode;
271
+ currentRoot = currentParent.shadowRoot;
272
+ } else if (currentParent.parentNode) {
273
+ currentParent = currentParent.parentNode;
274
+ currentRoot = null;
275
+ } else if (
276
+ currentRoot &&
277
+ currentRoot.host &&
278
+ currentRoot.host.nodeType === Node.DOCUMENT_NODE
279
+ ) {
280
+ currentParent = currentRoot.host;
281
+ currentRoot = null;
282
+ } else {
283
+ currentParent = null;
284
+ currentRoot = null;
285
+ }
286
+ }
287
+
288
+ return currentParent;
289
289
  }
290
290
 
291
291
  /**
@@ -297,17 +297,17 @@ function traverseShadowRoots(element) {
297
297
  * @since 3.36.0
298
298
  */
299
299
  function getContainingDocument(element) {
300
- if (
301
- !element ||
302
- !(
303
- element instanceof HTMLElement ||
304
- element instanceof element.ownerDocument.defaultView.HTMLElement
305
- )
306
- ) {
307
- throw new Error("Invalid argument. Expected an HTMLElement.");
308
- }
309
-
310
- return traverseShadowRoots(element) || null;
300
+ if (
301
+ !element ||
302
+ !(
303
+ element instanceof HTMLElement ||
304
+ element instanceof element.ownerDocument.defaultView.HTMLElement
305
+ )
306
+ ) {
307
+ throw new Error("Invalid argument. Expected an HTMLElement.");
308
+ }
309
+
310
+ return traverseShadowRoots(element) || null;
311
311
  }
312
312
 
313
313
  /**
@@ -318,11 +318,11 @@ function getContainingDocument(element) {
318
318
  * @return {string[]}
319
319
  */
320
320
  function getRegisteredCustomElements() {
321
- const customElementTags = Array.from(document.querySelectorAll("*"))
322
- .map((tag) => tag.tagName.toLowerCase())
323
- .filter((tagName) => tagName.includes("-") && customElements.get(tagName));
321
+ const customElementTags = Array.from(document.querySelectorAll("*"))
322
+ .map((tag) => tag.tagName.toLowerCase())
323
+ .filter((tagName) => tagName.includes("-") && customElements.get(tagName));
324
324
 
325
- return Array.from(new Set(customElementTags));
325
+ return Array.from(new Set(customElementTags));
326
326
  }
327
327
 
328
328
  /**
@@ -337,67 +337,67 @@ function getRegisteredCustomElements() {
337
337
  * @since 4.1.0
338
338
  */
339
339
  function waitForCustomElement(
340
- element,
341
- { method = null, tagName = null, timeout = 2000, readyCheck = null } = {},
340
+ element,
341
+ { method = null, tagName = null, timeout = 2000, readyCheck = null } = {},
342
342
  ) {
343
- if (!(element instanceof HTMLElement)) {
344
- return Promise.reject(
345
- new Error("Invalid argument. Expected an HTMLElement."),
346
- );
347
- }
348
-
349
- const name = (tagName || element.tagName || "").toLowerCase();
350
- if (!name.includes("-")) {
351
- return Promise.reject(
352
- new Error("Invalid argument. Expected a custom element tag name."),
353
- );
354
- }
355
-
356
- const window = getWindow();
357
- const registry = window.customElements;
358
- if (!registry) {
359
- return Promise.reject(new Error("customElements is not supported."));
360
- }
361
-
362
- return registry.whenDefined(name).then(
363
- () =>
364
- new Promise((resolve, reject) => {
365
- if (typeof registry.upgrade === "function") {
366
- registry.upgrade(element);
367
- }
368
-
369
- const start = Date.now();
370
- const isReady = () => {
371
- if (method && typeof element[method] !== "function") {
372
- return false;
373
- }
374
- if (typeof readyCheck === "function") {
375
- return readyCheck(element) === true;
376
- }
377
- return true;
378
- };
379
-
380
- const check = () => {
381
- if (isReady()) {
382
- resolve(element);
383
- return;
384
- }
385
-
386
- if (
387
- typeof timeout === "number" &&
388
- timeout >= 0 &&
389
- Date.now() - start > timeout
390
- ) {
391
- reject(
392
- new Error(`Timed out waiting for "${method}" on <${name}>.`),
393
- );
394
- return;
395
- }
396
-
397
- window.setTimeout(check, 0);
398
- };
399
-
400
- window.setTimeout(check, 0);
401
- }),
402
- );
343
+ if (!(element instanceof HTMLElement)) {
344
+ return Promise.reject(
345
+ new Error("Invalid argument. Expected an HTMLElement."),
346
+ );
347
+ }
348
+
349
+ const name = (tagName || element.tagName || "").toLowerCase();
350
+ if (!name.includes("-")) {
351
+ return Promise.reject(
352
+ new Error("Invalid argument. Expected a custom element tag name."),
353
+ );
354
+ }
355
+
356
+ const window = getWindow();
357
+ const registry = window.customElements;
358
+ if (!registry) {
359
+ return Promise.reject(new Error("customElements is not supported."));
360
+ }
361
+
362
+ return registry.whenDefined(name).then(
363
+ () =>
364
+ new Promise((resolve, reject) => {
365
+ if (typeof registry.upgrade === "function") {
366
+ registry.upgrade(element);
367
+ }
368
+
369
+ const start = Date.now();
370
+ const isReady = () => {
371
+ if (method && typeof element[method] !== "function") {
372
+ return false;
373
+ }
374
+ if (typeof readyCheck === "function") {
375
+ return readyCheck(element) === true;
376
+ }
377
+ return true;
378
+ };
379
+
380
+ const check = () => {
381
+ if (isReady()) {
382
+ resolve(element);
383
+ return;
384
+ }
385
+
386
+ if (
387
+ typeof timeout === "number" &&
388
+ timeout >= 0 &&
389
+ Date.now() - start > timeout
390
+ ) {
391
+ reject(
392
+ new Error(`Timed out waiting for "${method}" on <${name}>.`),
393
+ );
394
+ return;
395
+ }
396
+
397
+ window.setTimeout(check, 10);
398
+ };
399
+
400
+ window.setTimeout(check, 10);
401
+ }),
402
+ );
403
403
  }
@@ -15,6 +15,7 @@ let ButtonBar;
15
15
 
16
16
  describe("ButtonBar", function () {
17
17
  before(function (done) {
18
+ this.timeout(5000);
18
19
  initJSDOM()
19
20
  .then(() => {
20
21
  import("../../../../source/components/form/button-bar.mjs")