@schukai/monster 1.15.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. package/CHANGELOG +6 -0
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +1 -1
  4. package/dist/modules/constraints/abstract.js +2 -2
  5. package/dist/modules/constraints/abstractoperator.js +2 -2
  6. package/dist/modules/constraints/andoperator.js +2 -2
  7. package/dist/modules/constraints/invalid.js +2 -2
  8. package/dist/modules/constraints/isarray.js +2 -2
  9. package/dist/modules/constraints/isobject.js +2 -2
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +2 -2
  12. package/dist/modules/constraints/valid.js +2 -2
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/diff.js +2 -2
  15. package/dist/modules/data/extend.js +2 -2
  16. package/dist/modules/data/namespace.js +1 -1
  17. package/dist/modules/data/pathfinder.js +2 -2
  18. package/dist/modules/data/pipe.js +2 -2
  19. package/dist/modules/data/transformer.js +2 -2
  20. package/dist/modules/dom/assembler.js +2 -2
  21. package/dist/modules/dom/attributes.js +2 -2
  22. package/dist/modules/dom/constants.js +2 -2
  23. package/dist/modules/dom/customcontrol.js +2 -2
  24. package/dist/modules/dom/customelement.js +2 -2
  25. package/dist/modules/dom/events.js +2 -2
  26. package/dist/modules/dom/locale.js +2 -2
  27. package/dist/modules/dom/namespace.js +1 -1
  28. package/dist/modules/dom/template.js +2 -2
  29. package/dist/modules/dom/theme.js +2 -2
  30. package/dist/modules/dom/updater.js +2 -2
  31. package/dist/modules/dom/util.js +2 -2
  32. package/dist/modules/i18n/locale.js +2 -2
  33. package/dist/modules/i18n/namespace.js +1 -1
  34. package/dist/modules/i18n/provider.js +2 -2
  35. package/dist/modules/i18n/providers/fetch.js +2 -2
  36. package/dist/modules/i18n/providers/namespace.js +1 -1
  37. package/dist/modules/i18n/translations.js +2 -2
  38. package/dist/modules/logging/handler/console.js +2 -2
  39. package/dist/modules/logging/handler/namespace.js +1 -1
  40. package/dist/modules/logging/handler.js +2 -2
  41. package/dist/modules/logging/logentry.js +2 -2
  42. package/dist/modules/logging/logger.js +2 -2
  43. package/dist/modules/logging/namespace.js +1 -1
  44. package/dist/modules/math/namespace.js +1 -1
  45. package/dist/modules/math/random.js +2 -2
  46. package/dist/modules/monster.js +2 -2
  47. package/dist/modules/namespace.js +2 -2
  48. package/dist/modules/text/formatter.js +2 -2
  49. package/dist/modules/text/namespace.js +1 -1
  50. package/dist/modules/types/base.js +2 -2
  51. package/dist/modules/types/basewithoptions.js +2 -2
  52. package/dist/modules/types/global.js +2 -2
  53. package/dist/modules/types/id.js +2 -2
  54. package/dist/modules/types/is.js +2 -2
  55. package/dist/modules/types/namespace.js +1 -1
  56. package/dist/modules/types/observer.js +2 -2
  57. package/dist/modules/types/observerlist.js +2 -2
  58. package/dist/modules/types/proxyobserver.js +2 -2
  59. package/dist/modules/types/queue.js +2 -2
  60. package/dist/modules/types/randomid.js +2 -2
  61. package/dist/modules/types/stack.js +2 -2
  62. package/dist/modules/types/tokenlist.js +2 -2
  63. package/dist/modules/types/typeof.js +2 -2
  64. package/dist/modules/types/uniquequeue.js +2 -2
  65. package/dist/modules/types/validate.js +2 -2
  66. package/dist/modules/types/version.js +2 -2
  67. package/dist/modules/util/clone.js +2 -2
  68. package/dist/modules/util/comparator.js +2 -2
  69. package/dist/modules/util/freeze.js +2 -2
  70. package/dist/modules/util/namespace.js +1 -1
  71. package/dist/monster.dev.js +7321 -7322
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +2 -9
  74. package/package.json +1 -1
  75. package/source/constraints/abstract.js +1 -1
  76. package/source/constraints/abstractoperator.js +2 -2
  77. package/source/constraints/andoperator.js +7 -7
  78. package/source/constraints/invalid.js +4 -4
  79. package/source/constraints/isarray.js +6 -6
  80. package/source/constraints/isobject.js +6 -6
  81. package/source/constraints/namespace.js +2 -2
  82. package/source/constraints/oroperator.js +7 -7
  83. package/source/constraints/valid.js +6 -6
  84. package/source/data/buildmap.js +3 -3
  85. package/source/data/diff.js +8 -8
  86. package/source/data/extend.js +6 -6
  87. package/source/data/namespace.js +2 -2
  88. package/source/data/pathfinder.js +12 -12
  89. package/source/data/pipe.js +7 -7
  90. package/source/data/transformer.js +9 -9
  91. package/source/dom/assembler.js +6 -6
  92. package/source/dom/attributes.js +26 -27
  93. package/source/dom/constants.js +1 -1
  94. package/source/dom/customcontrol.js +80 -82
  95. package/source/dom/customelement.js +87 -87
  96. package/source/dom/events.js +7 -7
  97. package/source/dom/locale.js +4 -4
  98. package/source/dom/namespace.js +2 -2
  99. package/source/dom/template.js +23 -18
  100. package/source/dom/theme.js +7 -8
  101. package/source/dom/updater.js +18 -23
  102. package/source/dom/util.js +10 -10
  103. package/source/i18n/locale.js +5 -5
  104. package/source/i18n/namespace.js +1 -1
  105. package/source/i18n/provider.js +4 -4
  106. package/source/i18n/providers/fetch.js +7 -7
  107. package/source/i18n/translations.js +4 -4
  108. package/source/logging/handler/console.js +4 -4
  109. package/source/logging/handler/namespace.js +1 -1
  110. package/source/logging/handler.js +7 -7
  111. package/source/logging/logentry.js +4 -4
  112. package/source/logging/logger.js +4 -4
  113. package/source/logging/namespace.js +2 -2
  114. package/source/math/namespace.js +2 -2
  115. package/source/math/random.js +4 -4
  116. package/source/monster.js +42 -44
  117. package/source/namespace.js +2 -2
  118. package/source/text/formatter.js +5 -5
  119. package/source/text/namespace.js +1 -1
  120. package/source/types/base.js +3 -3
  121. package/source/types/basewithoptions.js +7 -7
  122. package/source/types/global.js +6 -6
  123. package/source/types/id.js +5 -5
  124. package/source/types/is.js +21 -21
  125. package/source/types/namespace.js +2 -2
  126. package/source/types/observer.js +6 -6
  127. package/source/types/observerlist.js +3 -3
  128. package/source/types/proxyobserver.js +21 -21
  129. package/source/types/queue.js +4 -4
  130. package/source/types/randomid.js +5 -5
  131. package/source/types/stack.js +3 -3
  132. package/source/types/tokenlist.js +8 -8
  133. package/source/types/typeof.js +4 -4
  134. package/source/types/uniquequeue.js +7 -7
  135. package/source/types/validate.js +26 -26
  136. package/source/types/version.js +7 -7
  137. package/source/util/clone.js +5 -5
  138. package/source/util/comparator.js +6 -6
  139. package/source/util/freeze.js +6 -6
  140. package/source/util/namespace.js +2 -2
  141. package/test/cases/dom/template.js +40 -1
  142. package/test/cases/monster.js +1 -1
  143. package/test/web/monster-dev.html +3 -3
  144. package/test/web/monster.html +2 -2
  145. package/test/web/test.html +3 -3
  146. package/test/web/tests.js +2 -2
@@ -1,22 +1,22 @@
1
1
  'use strict';
2
2
 
3
+ import {PROPERTY_KEY_INTERNALDATA} from "../constants.js";
4
+ import {extend} from "../data/extend.js";
5
+ import {Pathfinder} from "../data/pathfinder.js";
3
6
  /**
4
7
  * @author schukai GmbH
5
8
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
9
+ import {assignToNamespace, Monster} from '../namespace.js';
10
+ import {getGlobalObject} from "../types/global.js";
11
+ import {isString} from "../types/is.js";
7
12
  import {Observer} from "../types/observer.js";
8
13
  import {ProxyObserver} from "../types/proxyobserver.js";
9
- import { Updater} from "./updater.js";
10
- import {extend} from "../data/extend.js";
14
+ import {validateFunction, validateObject} from "../types/validate.js";
11
15
  import {clone} from "../util/clone.js";
12
- import {Pathfinder} from "../data/pathfinder.js";
16
+ import {addToObjectLink, getLinkedObjects, hasObjectLink} from "./attributes.js";
13
17
  import {ATTRIBUTE_OPTIONS, OBJECTLINK_KEY_UPDATER} from "./constants.js";
14
18
  import {findDocumentTemplate, Template} from "./template.js";
15
- import {addToObjectLink, getLinkedObjects, hasObjectLink} from "./attributes.js";
16
- import {getGlobalObject} from "../types/global.js";
17
- import {validateFunction, validateObject} from "../types/validate.js";
18
- import {isString} from "../types/is.js";
19
- import {PROPERTY_KEY_INTERNALDATA} from "../constants.js";
19
+ import {Updater} from "./updater.js";
20
20
 
21
21
  /**
22
22
  * @private
@@ -50,7 +50,7 @@ const assembleMethodSymbol = Symbol('assembleMethodSymbol');
50
50
  *
51
51
  * ```
52
52
  * <script type="module">
53
- * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/customelement.js';
53
+ * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/customelement.js';
54
54
  * console.log(new Monster.DOM.CustomElement())
55
55
  * </script>
56
56
  * ```
@@ -59,7 +59,7 @@ const assembleMethodSymbol = Symbol('assembleMethodSymbol');
59
59
  *
60
60
  * ```
61
61
  * <script type="module">
62
- * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/customelement.js';
62
+ * import {CustomElement} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/customelement.js';
63
63
  * console.log(new CustomElement())
64
64
  * </script>
65
65
  * ```
@@ -163,33 +163,13 @@ class CustomElement extends HTMLElement {
163
163
  }
164
164
 
165
165
  /**
166
- * attach a new observer
167
- *
168
- * @param {Observer} observer
169
- * @returns {CustomElement}
170
- */
171
- attachObserver(observer) {
172
- this[internalDataSymbol].attachObserver(observer)
173
- return this;
174
- }
175
-
176
- /**
177
- * detach a observer
166
+ * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
178
167
  *
179
- * @param {Observer} observer
180
- * @returns {CustomElement}
181
- */
182
- detachObserver(observer) {
183
- this[internalDataSymbol].detachObserver(observer)
184
- return this;
185
- }
186
-
187
- /**
188
- * @param {Observer} observer
189
- * @returns {ProxyObserver}
168
+ * @return {string[]}
169
+ * @since 1.15.0
190
170
  */
191
- containsObserver(observer) {
192
- return this[internalDataSymbol].containsObserver(observer)
171
+ static get observedAttributes() {
172
+ return [ATTRIBUTE_OPTIONS];
193
173
  }
194
174
 
195
175
  /**
@@ -223,6 +203,75 @@ class CustomElement extends HTMLElement {
223
203
  };
224
204
  }
225
205
 
206
+ /**
207
+ * There is no check on the name by this class. the developer is responsible for assigning an appropriate tag.
208
+ * if the name is not valid, registerCustomElement() will issue an error
209
+ *
210
+ * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
211
+ * @return {string}
212
+ * @throws {Error} the method getTag must be overwritten by the derived class.
213
+ * @since 1.7.0
214
+ */
215
+ static getTag() {
216
+ throw new Error("the method getTag must be overwritten by the derived class.");
217
+ }
218
+
219
+ /**
220
+ * At this point a `CSSStyleSheet` object can be returned. If the environment does not
221
+ * support a constructor, then an object can also be built using the following detour.
222
+ *
223
+ * If `undefined` is returned then the shadowRoot does not get a stylesheet.
224
+ *
225
+ * ```
226
+ * const doc = document.implementation.createHTMLDocument('title');
227
+ *
228
+ * let style = doc.createElement("style");
229
+ * style.innerHTML="p{color:red;}";
230
+ *
231
+ * // WebKit Hack
232
+ * style.appendChild(document.createTextNode(""));
233
+ * // Add the <style> element to the page
234
+ * doc.head.appendChild(style);
235
+ * return doc.styleSheets[0];
236
+ * ;
237
+ * ```
238
+ *
239
+ * @return {CSSStyleSheet|undefined}
240
+ */
241
+ static getCSSStyleSheet() {
242
+ return undefined;
243
+ }
244
+
245
+ /**
246
+ * attach a new observer
247
+ *
248
+ * @param {Observer} observer
249
+ * @returns {CustomElement}
250
+ */
251
+ attachObserver(observer) {
252
+ this[internalDataSymbol].attachObserver(observer)
253
+ return this;
254
+ }
255
+
256
+ /**
257
+ * detach a observer
258
+ *
259
+ * @param {Observer} observer
260
+ * @returns {CustomElement}
261
+ */
262
+ detachObserver(observer) {
263
+ this[internalDataSymbol].detachObserver(observer)
264
+ return this;
265
+ }
266
+
267
+ /**
268
+ * @param {Observer} observer
269
+ * @returns {ProxyObserver}
270
+ */
271
+ containsObserver(observer) {
272
+ return this[internalDataSymbol].containsObserver(observer)
273
+ }
274
+
226
275
  /**
227
276
  * nested options can be specified by path `a.b.c`
228
277
  *
@@ -272,7 +321,7 @@ class CustomElement extends HTMLElement {
272
321
  const self = this;
273
322
  extend(self[internalDataSymbol].getSubject()['options'], self.defaults, options);
274
323
  //this[internalDataSymbol].notifyObservers();
275
-
324
+
276
325
  return self;
277
326
  }
278
327
 
@@ -364,16 +413,6 @@ class CustomElement extends HTMLElement {
364
413
 
365
414
  }
366
415
 
367
- /**
368
- * This method determines which attributes are to be monitored by `attributeChangedCallback()`.
369
- *
370
- * @return {string[]}
371
- * @since 1.15.0
372
- */
373
- static get observedAttributes() {
374
- return [ATTRIBUTE_OPTIONS];
375
- }
376
-
377
416
  /**
378
417
  * Called when an observed attribute has been added, removed, updated, or replaced. Also called for initial
379
418
  * values when an element is created by the parser, or upgraded. Note: only attributes listed in the observedAttributes
@@ -394,45 +433,6 @@ class CustomElement extends HTMLElement {
394
433
 
395
434
  }
396
435
 
397
- /**
398
- * There is no check on the name by this class. the developer is responsible for assigning an appropriate tag.
399
- * if the name is not valid, registerCustomElement() will issue an error
400
- *
401
- * @link https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
402
- * @return {string}
403
- * @throws {Error} the method getTag must be overwritten by the derived class.
404
- * @since 1.7.0
405
- */
406
- static getTag() {
407
- throw new Error("the method getTag must be overwritten by the derived class.");
408
- }
409
-
410
- /**
411
- * At this point a `CSSStyleSheet` object can be returned. If the environment does not
412
- * support a constructor, then an object can also be built using the following detour.
413
- *
414
- * If `undefined` is returned then the shadowRoot does not get a stylesheet.
415
- *
416
- * ```
417
- * const doc = document.implementation.createHTMLDocument('title');
418
- *
419
- * let style = doc.createElement("style");
420
- * style.innerHTML="p{color:red;}";
421
- *
422
- * // WebKit Hack
423
- * style.appendChild(document.createTextNode(""));
424
- * // Add the <style> element to the page
425
- * doc.head.appendChild(style);
426
- * return doc.styleSheets[0];
427
- * ;
428
- * ```
429
- *
430
- * @return {CSSStyleSheet|undefined}
431
- */
432
- static getCSSStyleSheet() {
433
- return undefined;
434
- }
435
-
436
436
  }
437
437
 
438
438
  /**
@@ -448,7 +448,7 @@ function initOptionObserver() {
448
448
  if (!hasObjectLink(self, Symbol.for(OBJECTLINK_KEY_UPDATER))) {
449
449
  return;
450
450
  }
451
- // inform every element
451
+ // inform every element
452
452
  const updaters = getLinkedObjects(self, Symbol.for(OBJECTLINK_KEY_UPDATER));
453
453
 
454
454
  for (const list of updaters) {
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
6
+ import {assignToNamespace, Monster} from '../namespace.js';
7
7
  import {validateInstance, validateString} from "../types/validate.js";
8
8
  import {findClosestByAttribute} from "./attributes.js";
9
9
  import {getDocument} from "./util.js";
@@ -13,7 +13,7 @@ import {getDocument} from "./util.js";
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/events.js';
17
17
  * console.log(new Monster.DOM.fireEvent())
18
18
  * </script>
19
19
  * ```
@@ -22,7 +22,7 @@ import {getDocument} from "./util.js";
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
25
+ * import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/events.js';
26
26
  * console.log(fireEvent())
27
27
  * </script>
28
28
  * ```
@@ -64,14 +64,14 @@ function fireEvent(element, type) {
64
64
  }
65
65
 
66
66
  /**
67
- * This function gets the path `Event.composedPath()` from an event and tries to find the next element
67
+ * This function gets the path `Event.composedPath()` from an event and tries to find the next element
68
68
  * up the tree `element.closest()` with the attribute and value. If no value is specified, only the attribute is searched.
69
69
  *
70
70
  * You can call the function via the monster namespace `new Monster.DOM.findTargetElementFromEvent()`.
71
71
  *
72
72
  * ```
73
73
  * <script type="module">
74
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
74
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/events.js';
75
75
  * console.log(new Monster.DOM.findTargetElementFromEvent())
76
76
  * </script>
77
77
  * ```
@@ -80,11 +80,11 @@ function fireEvent(element, type) {
80
80
  *
81
81
  * ```
82
82
  * <script type="module">
83
- * import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/events.js';
83
+ * import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/events.js';
84
84
  * console.log(findTargetElementFromEvent())
85
85
  * </script>
86
86
  * ```
87
- *
87
+ *
88
88
  * @since 1.14.0
89
89
  * @param {Event} event
90
90
  * @param {string} attributeName
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ import {parseLocale} from "../i18n/locale.js";
3
4
  /**
4
5
  * @author schukai GmbH
5
6
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
7
- import { parseLocale} from "../i18n/locale.js";
7
+ import {assignToNamespace, Monster} from '../namespace.js';
8
8
  import {getDocument} from "./util.js";
9
9
 
10
10
  /**
@@ -20,7 +20,7 @@ const DEFAULT_LANGUAGE = 'en';
20
20
  *
21
21
  * ```
22
22
  * <script type="module">
23
- * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/locale.js';
23
+ * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/locale.js';
24
24
  * console.log(new Monster.DOM.getLocaleOfDocument())
25
25
  * </script>
26
26
  * ```
@@ -29,7 +29,7 @@ const DEFAULT_LANGUAGE = 'en';
29
29
  *
30
30
  * ```
31
31
  * <script type="module">
32
- * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/locale.js';
32
+ * import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/locale.js';
33
33
  * console.log(new getLocaleOfDocument())
34
34
  * </script>
35
35
  * ```
@@ -2,7 +2,7 @@
2
2
 
3
3
  /**
4
4
  * In this namespace you will find classes and methods for handling the DOM.
5
- *
5
+ *
6
6
  * @namespace Monster/DOM
7
7
  * @author schukai GmbH
8
8
  */
@@ -11,4 +11,4 @@
11
11
  * @private
12
12
  * @type {string}
13
13
  */
14
- const namespace="Monster.DOM";
14
+ const namespace = "Monster.DOM";
@@ -3,11 +3,10 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
7
- import { Base} from '../types/base.js';
8
- import {validateString} from "../types/validate.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
7
+ import {Base} from '../types/base.js';
9
8
  import {getGlobalFunction, getGlobalObject} from '../types/global.js';
10
- import {validateInstance} from "../types/validate.js";
9
+ import {validateInstance, validateString} from "../types/validate.js";
11
10
  import {getDocumentTheme} from "./theme.js";
12
11
 
13
12
  /**
@@ -15,7 +14,7 @@ import {getDocumentTheme} from "./theme.js";
15
14
  *
16
15
  * ```
17
16
  * <script type="module">
18
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
17
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/template.js';
19
18
  * console.log(new Monster.DOM.Template())
20
19
  * </script>
21
20
  * ```
@@ -24,7 +23,7 @@ import {getDocumentTheme} from "./theme.js";
24
23
  *
25
24
  * ```
26
25
  * <script type="module">
27
- * import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
26
+ * import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/template.js';
28
27
  * console.log(new Template())
29
28
  * </script>
30
29
  * ```
@@ -74,7 +73,7 @@ class Template extends Base {
74
73
  *
75
74
  * ```
76
75
  * <script type="module">
77
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
76
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/template.js';
78
77
  * console.log(Monster.DOM.findDocumentTemplate())
79
78
  * </script>
80
79
  * ```
@@ -83,13 +82,13 @@ class Template extends Base {
83
82
  *
84
83
  * ```
85
84
  * <script type="module">
86
- * import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/template.js';
85
+ * import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/template.js';
87
86
  * console.log(findDocumentTemplate())
88
87
  * </script>
89
88
  * ```
90
89
  *
91
90
  * @param {string} id
92
- * @param {Node} root
91
+ * @param {Node} currentNode
93
92
  * @return {Template}
94
93
  * @since 1.7.0
95
94
  * @copyright schukai GmbH
@@ -97,29 +96,35 @@ class Template extends Base {
97
96
  * @throws {Error} template id not found.
98
97
  * @throws {TypeError} value is not a string
99
98
  */
100
- function findDocumentTemplate(id, root) {
99
+ function findDocumentTemplate(id, currentNode) {
101
100
  validateString(id);
102
-
103
- if (!(root instanceof Node)) {
104
- root = getGlobalObject('document');
101
+
102
+ if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
103
+ if (currentNode instanceof Node) {
104
+ currentNode = currentNode.ownerDocument;
105
+ }
106
+
107
+ if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
108
+ currentNode = getGlobalObject('document');
109
+ }
105
110
  }
106
-
111
+
107
112
  const HTMLTemplateElement = getGlobalFunction('HTMLTemplateElement');
108
113
 
109
114
  let theme = getDocumentTheme()
110
115
  let themedID = id + '-' + theme.getName();
111
116
 
112
- let template = root.getElementById(themedID);
117
+ let template = currentNode.getElementById(themedID);
113
118
  if (template instanceof HTMLTemplateElement) {
114
119
  return new Template(template);
115
120
  }
116
121
 
117
- template = root.getElementById(id);
122
+ template = currentNode.getElementById(id);
118
123
  if (template instanceof HTMLTemplateElement) {
119
124
  return new Template(template);
120
125
  }
121
-
122
- if(root!==getGlobalObject('document')) {
126
+
127
+ if (currentNode !== getGlobalObject('document')) {
123
128
  return findDocumentTemplate(id)
124
129
  }
125
130
 
@@ -3,20 +3,19 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
7
- import { Base} from '../types/base.js';
8
- import {validateString} from "../types/validate.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
7
+ import {Base} from '../types/base.js';
9
8
  import {getGlobalObject} from '../types/global.js';
9
+ import {validateString} from "../types/validate.js";
10
10
  import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
11
11
 
12
12
 
13
-
14
13
  /**
15
14
  * You can call the method via the monster namespace `new Monster.DOM.Theme()`.
16
15
  *
17
16
  * ```
18
17
  * <script type="module">
19
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
18
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/theme.js';
20
19
  * console.log(new Monster.DOM.Theme())
21
20
  * </script>
22
21
  * ```
@@ -25,14 +24,14 @@ import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
25
24
  *
26
25
  * ```
27
26
  * <script type="module">
28
- * import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
27
+ * import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/theme.js';
29
28
  * console.log(new Theme())
30
29
  * </script>
31
30
  * ```
32
- *
31
+ *
33
32
  * @example
34
33
  *
35
- * import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/theme.js';
34
+ * import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/theme.js';
36
35
  *
37
36
  * const theme = getDocumentTheme();
38
37
  * console.log(theme.getName());
@@ -1,26 +1,26 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * @author schukai GmbH
5
- */
6
- import {Monster, assignToNamespace} from '../namespace.js';
3
+ import {Diff} from "../data/diff.js";
7
4
  import {Pathfinder} from "../data/pathfinder.js";
8
5
  import {Pipe} from "../data/pipe.js";
9
- import {Base} from "../types/base.js";
10
- import {isInstance, isArray, isIterable} from "../types/is.js";
11
- import {Observer} from "../types/observer.js";
12
- import {ProxyObserver} from "../types/proxyobserver.js";
13
- import {validateInstance, validateArray} from "../types/validate.js";
14
- import {clone} from "../util/clone.js";
15
- import {Diff} from "../data/diff.js";
16
6
  import {
17
- ATTRIBUTE_UPDATER_REPLACE,
18
7
  ATTRIBUTE_UPDATER_ATTRIBUTES,
8
+ ATTRIBUTE_UPDATER_BIND,
19
9
  ATTRIBUTE_UPDATER_INSERT,
20
- ATTRIBUTE_UPDATER_REMOVE,
21
10
  ATTRIBUTE_UPDATER_INSERT_REFERENCE,
22
- ATTRIBUTE_UPDATER_BIND
11
+ ATTRIBUTE_UPDATER_REMOVE,
12
+ ATTRIBUTE_UPDATER_REPLACE
23
13
  } from "../dom/constants.js";
14
+ /**
15
+ * @author schukai GmbH
16
+ */
17
+ import {assignToNamespace, Monster} from '../namespace.js';
18
+ import {Base} from "../types/base.js";
19
+ import {isArray, isInstance, isIterable} from "../types/is.js";
20
+ import {Observer} from "../types/observer.js";
21
+ import {ProxyObserver} from "../types/proxyobserver.js";
22
+ import {validateArray, validateInstance} from "../types/validate.js";
23
+ import {clone} from "../util/clone.js";
24
24
  import {findDocumentTemplate} from "./template.js";
25
25
  import {getDocument} from "./util.js";
26
26
 
@@ -34,7 +34,7 @@ import {getDocument} from "./util.js";
34
34
  *
35
35
  * ```
36
36
  * <script type="module">
37
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
37
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/updater.js';
38
38
  * console.log(new Monster.DOM.Updater())
39
39
  * </script>
40
40
  * ```
@@ -43,14 +43,14 @@ import {getDocument} from "./util.js";
43
43
  *
44
44
  * ```
45
45
  * <script type="module">
46
- * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
46
+ * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/updater.js';
47
47
  * console.log(new Updater())
48
48
  * </script>
49
49
  * ```
50
50
  *
51
51
  * @example
52
52
  *
53
- * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
53
+ * import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/updater.js';
54
54
  *
55
55
  * // First we prepare the html document.
56
56
  * // This is done here via script, but can also be inserted into the document as pure html.
@@ -492,12 +492,7 @@ function insertElement(change) {
492
492
  */
493
493
  function appendNewDocumentFragment(container, key, ref, path) {
494
494
 
495
- let rootNode = container.getRootNode();
496
- if (!rootNode) {
497
- rootNode = getDocument();
498
- }
499
-
500
- let template = findDocumentTemplate(key, rootNode);
495
+ let template = findDocumentTemplate(key, container);
501
496
 
502
497
  let nodes = template.createDocumentFragment();
503
498
  for (const [, node] of Object.entries(nodes.childNodes)) {
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
- import {Monster, assignToNamespace} from '../namespace.js';
7
- import { getGlobal} from "../types/global.js";
6
+ import {assignToNamespace, Monster} from '../namespace.js';
7
+ import {getGlobal} from "../types/global.js";
8
8
  import {validateString} from "../types/validate.js";
9
9
 
10
10
 
@@ -13,7 +13,7 @@ import {validateString} from "../types/validate.js";
13
13
  *
14
14
  * ```
15
15
  * <script type="module">
16
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
16
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
17
17
  * console.log(Monster.DOM.getDocument())
18
18
  * </script>
19
19
  * ```
@@ -22,7 +22,7 @@ import {validateString} from "../types/validate.js";
22
22
  *
23
23
  * ```
24
24
  * <script type="module">
25
- * import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
25
+ * import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
26
26
  * console.log(getDocument())
27
27
  * </script>
28
28
  * ```
@@ -62,7 +62,7 @@ import {validateString} from "../types/validate.js";
62
62
  */
63
63
  function getDocument() {
64
64
  let document = getGlobal()?.['document'];
65
- if (typeof document !== 'object') {
65
+ if (typeof document !== 'object') {
66
66
  throw new Error("not supported environment")
67
67
  }
68
68
 
@@ -74,7 +74,7 @@ function getDocument() {
74
74
  *
75
75
  * ```
76
76
  * <script type="module">
77
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
77
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
78
78
  * console.log(Monster.DOM.getWindow())
79
79
  * </script>
80
80
  * ```
@@ -83,7 +83,7 @@ function getDocument() {
83
83
  *
84
84
  * ```
85
85
  * <script type="module">
86
- * import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
86
+ * import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
87
87
  * console.log(getWindow(null))
88
88
  * </script>
89
89
  * ```
@@ -140,7 +140,7 @@ function getWindow() {
140
140
  *
141
141
  * ```
142
142
  * <script type="module">
143
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
143
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
144
144
  * console.log(Monster.DOM.getDocumentFragmentFromString())
145
145
  * </script>
146
146
  * ```
@@ -149,7 +149,7 @@ function getWindow() {
149
149
  *
150
150
  * ```
151
151
  * <script type="module">
152
- * import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/util.js';
152
+ * import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.2/dist/modules/dom/util.js';
153
153
  * console.log(getDocumentFragmentFromString('<div></div>'))
154
154
  * </script>
155
155
  * ```
@@ -194,7 +194,7 @@ function getDocumentFragmentFromString(html) {
194
194
  const document = getDocument();
195
195
  const template = document.createElement('template');
196
196
  template.innerHTML = html;
197
-
197
+
198
198
  return template.content;
199
199
  }
200
200