@schukai/monster 1.12.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. package/CHANGELOG +40 -1
  2. package/README.md +5 -5
  3. package/dist/modules/constants.js +2 -0
  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 -0
  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 -0
  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 -0
  33. package/dist/modules/i18n/namespace.js +2 -0
  34. package/dist/modules/i18n/provider.js +2 -0
  35. package/dist/modules/i18n/providers/fetch.js +2 -0
  36. package/dist/modules/i18n/providers/namespace.js +2 -0
  37. package/dist/modules/i18n/translations.js +2 -0
  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 +1 -1
  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 -0
  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 +8692 -6669
  72. package/dist/monster.dev.js.map +1 -1
  73. package/dist/monster.js +3 -3
  74. package/package.json +1 -1
  75. package/source/constants.js +22 -0
  76. package/source/constraints/abstract.js +2 -2
  77. package/source/constraints/abstractoperator.js +3 -3
  78. package/source/constraints/andoperator.js +7 -7
  79. package/source/constraints/invalid.js +6 -6
  80. package/source/constraints/isarray.js +6 -6
  81. package/source/constraints/isobject.js +6 -6
  82. package/source/constraints/namespace.js +2 -0
  83. package/source/constraints/oroperator.js +8 -8
  84. package/source/constraints/valid.js +6 -6
  85. package/source/data/buildmap.js +15 -15
  86. package/source/data/diff.js +6 -6
  87. package/source/data/extend.js +55 -13
  88. package/source/data/namespace.js +2 -0
  89. package/source/data/pathfinder.js +6 -7
  90. package/source/data/pipe.js +5 -5
  91. package/source/data/transformer.js +6 -6
  92. package/source/dom/assembler.js +5 -5
  93. package/source/dom/attributes.js +89 -45
  94. package/source/dom/constants.js +8 -9
  95. package/source/dom/customcontrol.js +301 -0
  96. package/source/dom/customelement.js +149 -31
  97. package/source/dom/events.js +58 -8
  98. package/source/dom/locale.js +59 -0
  99. package/source/dom/namespace.js +2 -0
  100. package/source/dom/template.js +7 -7
  101. package/source/dom/theme.js +6 -6
  102. package/source/dom/updater.js +38 -11
  103. package/source/dom/util.js +10 -10
  104. package/source/i18n/locale.js +322 -0
  105. package/source/i18n/namespace.js +15 -0
  106. package/source/i18n/provider.js +58 -0
  107. package/source/i18n/providers/fetch.js +121 -0
  108. package/source/i18n/providers/namespace.js +15 -0
  109. package/source/i18n/translations.js +209 -0
  110. package/source/logging/handler/console.js +4 -4
  111. package/source/logging/handler.js +4 -4
  112. package/source/logging/logentry.js +4 -4
  113. package/source/logging/logger.js +4 -4
  114. package/source/logging/namespace.js +2 -0
  115. package/source/math/namespace.js +2 -0
  116. package/source/math/random.js +5 -5
  117. package/source/monster.js +26 -16
  118. package/source/namespace.js +10 -8
  119. package/source/text/formatter.js +4 -5
  120. package/source/text/namespace.js +1 -1
  121. package/source/types/base.js +4 -7
  122. package/source/types/basewithoptions.js +97 -0
  123. package/source/types/global.js +6 -6
  124. package/source/types/id.js +6 -6
  125. package/source/types/is.js +22 -22
  126. package/source/types/namespace.js +3 -1
  127. package/source/types/observer.js +5 -5
  128. package/source/types/observerlist.js +4 -4
  129. package/source/types/proxyobserver.js +32 -26
  130. package/source/types/queue.js +13 -7
  131. package/source/types/randomid.js +5 -5
  132. package/source/types/stack.js +11 -4
  133. package/source/types/tokenlist.js +4 -4
  134. package/source/types/typeof.js +5 -5
  135. package/source/types/uniquequeue.js +11 -4
  136. package/source/types/validate.js +22 -22
  137. package/source/types/version.js +9 -9
  138. package/source/util/clone.js +4 -4
  139. package/source/util/comparator.js +6 -6
  140. package/source/util/freeze.js +4 -4
  141. package/source/util/namespace.js +2 -0
  142. package/test/cases/data/extend.js +66 -13
  143. package/test/cases/dom/attributes.js +56 -1
  144. package/test/cases/dom/customcontrol.js +264 -0
  145. package/test/cases/dom/customelement.js +112 -51
  146. package/test/cases/dom/events.js +32 -14
  147. package/test/cases/dom/locale.js +44 -0
  148. package/test/cases/i18n/locale.js +80 -0
  149. package/test/cases/i18n/provider.js +15 -0
  150. package/test/cases/i18n/providers/fetch.js +65 -0
  151. package/test/cases/i18n/translations.js +57 -0
  152. package/test/cases/monster.js +3 -1
  153. package/test/cases/{util → text}/formatter.js +2 -0
  154. package/test/cases/types/basewithoptions.js +25 -0
  155. package/test/cases/types/proxyobserver.js +9 -0
  156. package/test/cases/{text → util}/clone.js +0 -0
  157. package/test/cases/{text → util}/comparator.js +0 -0
  158. package/test/util/jsdom.js +4 -0
  159. package/test/web/import.js +10 -3
  160. package/test/web/monster-dev.html +3 -3
  161. package/test/web/monster.html +3 -3
  162. package/test/web/test.html +3 -3
  163. package/test/web/tests.js +3 -3
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {Transformer} from './transformer.js';
9
9
  import {Base} from '../types/base.js';
10
10
  import {validateFunction, validateString} from '../types/validate.js';
@@ -19,7 +19,7 @@ const DELIMITER = '|';
19
19
  *
20
20
  * ```
21
21
  * <script type="module">
22
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/pipe.js';
22
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pipe.js';
23
23
  * console.log(new Monster.Data.Pipe())
24
24
  * </script>
25
25
  * ```
@@ -28,7 +28,7 @@ const DELIMITER = '|';
28
28
  *
29
29
  * ```
30
30
  * <script type="module">
31
- * import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/pipe.js';
31
+ * import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pipe.js';
32
32
  * console.log(new Pipe())
33
33
  * </script>
34
34
  * ```
@@ -39,7 +39,7 @@ const DELIMITER = '|';
39
39
  * the word is then converted to uppercase letters and a prefix Hello is added. the two backslash safe the space char.
40
40
  *
41
41
  * @example
42
- * import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/pipe.js';
42
+ * import {Pipe} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/pipe.js';
43
43
  *
44
44
  * let obj = {
45
45
  * a: {
@@ -106,5 +106,5 @@ class Pipe extends Base {
106
106
  }
107
107
  }
108
108
 
109
- Monster.assignToNamespace('Monster.Data', Pipe);
109
+ assignToNamespace('Monster.Data', Pipe);
110
110
  export {Monster, Pipe}
@@ -3,8 +3,7 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster} from '../namespace.js';
6
+ import {Monster, assignToNamespace} from '../namespace.js';
8
7
  import {Base} from '../types/base.js';
9
8
  import {getGlobal} from "../types/global.js";
10
9
  import {
@@ -26,7 +25,7 @@ import {Pathfinder} from "./pathfinder.js";
26
25
  *
27
26
  * ```
28
27
  * <script type="module">
29
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/transformer.js';
28
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/transformer.js';
30
29
  * console.log(new Monster.Data.Transformer())
31
30
  * </script>
32
31
  * ```
@@ -35,7 +34,7 @@ import {Pathfinder} from "./pathfinder.js";
35
34
  *
36
35
  * ```
37
36
  * <script type="module">
38
- * import {Transformer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/transformer.js';
37
+ * import {Transformer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/transformer.js';
39
38
  * console.log(new Transformer())
40
39
  * </script>
41
40
  * ```
@@ -114,7 +113,7 @@ import {Pathfinder} from "./pathfinder.js";
114
113
  *
115
114
  * @example
116
115
  *
117
- * import {Transformer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/data/transformer.js';
116
+ * import {Transformer} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/data/transformer.js';
118
117
  *
119
118
  * const transformer = new Transformer("tolower")
120
119
  *
@@ -181,7 +180,7 @@ class Transformer extends Base {
181
180
  }
182
181
  }
183
182
 
184
- Monster.assignToNamespace('Monster.Data', Transformer);
183
+ assignToNamespace('Monster.Data', Transformer);
185
184
  export {Monster, Transformer}
186
185
 
187
186
  /**
@@ -465,3 +464,4 @@ function transform(value) {
465
464
 
466
465
  return value;
467
466
  }
467
+
@@ -3,8 +3,8 @@
3
3
  /**
4
4
  * @author schukai GmbH
5
5
  */
6
-
7
- import {Monster, Base} from '../types/base.js';
6
+ import {Monster, assignToNamespace} from '../namespace.js';
7
+ import { Base} from '../types/base.js';
8
8
  import {validateInstance, validateString} from "../types/validate.js";
9
9
  import {getGlobalFunction} from "../types/global.js";
10
10
  import {ProxyObserver} from "../types/proxyobserver.js";
@@ -23,7 +23,7 @@ const ATTRIBUTEPREFIX = "data-monster-";
23
23
  *
24
24
  * ```
25
25
  * <script type="module">
26
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/assembler.js';
26
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/assembler.js';
27
27
  * console.log(new Monster.DOM.Assembler())
28
28
  * </script>
29
29
  * ```
@@ -32,7 +32,7 @@ const ATTRIBUTEPREFIX = "data-monster-";
32
32
  *
33
33
  * ```
34
34
  * <script type="module">
35
- * import {Assembler} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/assembler.js';
35
+ * import {Assembler} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/assembler.js';
36
36
  * console.log(new Assembler())
37
37
  * </script>
38
38
  * ```
@@ -95,5 +95,5 @@ class Assembler extends Base {
95
95
 
96
96
  }
97
97
 
98
- Monster.assignToNamespace('Monster.DOM', Assembler);
98
+ assignToNamespace('Monster.DOM', Assembler);
99
99
  export {Monster, ATTRIBUTEPREFIX, Assembler}
@@ -4,7 +4,7 @@
4
4
  * @author schukai GmbH
5
5
  */
6
6
 
7
- import {Monster} from '../namespace.js';
7
+ import {Monster, assignToNamespace} from '../namespace.js';
8
8
  import {getGlobalFunction} from "../types/global.js";
9
9
  import {isInstance} from "../types/is.js";
10
10
  import {TokenList} from "../types/tokenlist.js";
@@ -21,7 +21,7 @@ import {ATTRIBUTE_OBJECTLINK} from "./constants.js";
21
21
  *
22
22
  * ```
23
23
  * <script type="module">
24
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/updater.js';
24
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
25
25
  * console.log(Monster.DOM.findClosestObjectLink())
26
26
  * </script>
27
27
  * ```
@@ -30,30 +30,20 @@ import {ATTRIBUTE_OBJECTLINK} from "./constants.js";
30
30
  *
31
31
  * ```
32
32
  * <script type="module">
33
- * import {getUpdaterFromNode} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/updater.js';
33
+ * import {getUpdaterFromNode} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/updater.js';
34
34
  * console.log(findClosestObjectLink())
35
35
  * </script>
36
36
  * ```
37
37
  *
38
- * @param {Node} node
39
- * @return {Node|undefined}
38
+ * @param {HTMLElement} element
39
+ * @return {HTMLElement|undefined}
40
40
  * @since 1.10.0
41
41
  * @copyright schukai GmbH
42
42
  * @memberOf Monster/DOM
43
- * @throws {TypeError} value is not an instance of Node
43
+ * @throws {TypeError} value is not an instance of HTMLElement
44
44
  */
45
- function findClosestObjectLink(node) {
46
- validateInstance(node, getGlobalFunction('Node'));
47
-
48
- let attribute = node.hasAttribute(ATTRIBUTE_OBJECTLINK);
49
- if (attribute === false) {
50
- let parentNode = node?.['parentNode'];
51
- if (isInstance(parentNode, getGlobalFunction('Node'))) {
52
- return findClosestObjectLink(parentNode)
53
- }
54
- }
55
-
56
- return node;
45
+ function findClosestObjectLink(element) {
46
+ return findClosestByAttribute(element, ATTRIBUTE_OBJECTLINK);
57
47
  }
58
48
 
59
49
  /**
@@ -61,7 +51,7 @@ function findClosestObjectLink(node) {
61
51
  *
62
52
  * ```
63
53
  * <script type="module">
64
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
54
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
65
55
  * Monster.DOM.addToObjectLink();
66
56
  * </script>
67
57
  * ```
@@ -70,7 +60,7 @@ function findClosestObjectLink(node) {
70
60
  *
71
61
  * ```
72
62
  * <script type="module">
73
- * import {addToObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
63
+ * import {addToObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
74
64
  * addToObjectLink();
75
65
  * </script>
76
66
  * ```
@@ -103,7 +93,7 @@ function addToObjectLink(element, symbol, object) {
103
93
  *
104
94
  * ```
105
95
  * <script type="module">
106
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
96
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
107
97
  * Monster.DOM.removeObjectLink();
108
98
  * </script>
109
99
  * ```
@@ -112,7 +102,7 @@ function addToObjectLink(element, symbol, object) {
112
102
  *
113
103
  * ```
114
104
  * <script type="module">
115
- * import {removeObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
105
+ * import {removeObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
116
106
  * removeObjectLink();
117
107
  * </script>
118
108
  * ```
@@ -145,7 +135,7 @@ function removeObjectLink(element, symbol) {
145
135
  *
146
136
  * ```
147
137
  * <script type="module">
148
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
138
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
149
139
  * Monster.DOM.hasObjectLink();
150
140
  * </script>
151
141
  * ```
@@ -154,7 +144,7 @@ function removeObjectLink(element, symbol) {
154
144
  *
155
145
  * ```
156
146
  * <script type="module">
157
- * import {hasObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
147
+ * import {hasObjectLink} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
158
148
  * hasObjectLink();
159
149
  * </script>
160
150
  * ```
@@ -180,18 +170,18 @@ function hasObjectLink(element, symbol) {
180
170
  }
181
171
 
182
172
  /**
183
- * The ObjectLink can be used to attach objects to HTMLElements. The elements are kept in a set under a unique
184
- * symbol and can be read via an iterator {@see getLinkedObjects}.
185
- *
173
+ * The ObjectLink can be used to attach objects to HTMLElements. The elements are kept in a set under a unique
174
+ * symbol and can be read via an iterator {@see getLinkedObjects}.
175
+ *
186
176
  * In addition, elements with an objectLink receive the attribute `data-monster-objectlink`.
187
- *
177
+ *
188
178
  * With the method {@see addToObjectLink} the objects can be added.
189
- *
179
+ *
190
180
  * You can call the method via the monster namespace `new Monster.DOM.getLinkedObjects()`.
191
181
  *
192
182
  * ```
193
183
  * <script type="module">
194
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
184
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
195
185
  * Monster.DOM.getLinkedObjects();
196
186
  * </script>
197
187
  * ```
@@ -200,7 +190,7 @@ function hasObjectLink(element, symbol) {
200
190
  *
201
191
  * ```
202
192
  * <script type="module">
203
- * import {getLinkedObjects} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
193
+ * import {getLinkedObjects} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
204
194
  * getLinkedObjects();
205
195
  * </script>
206
196
  * ```
@@ -236,7 +226,7 @@ function getLinkedObjects(element, symbol) {
236
226
  *
237
227
  * ```
238
228
  * <script type="module">
239
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
229
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
240
230
  * Monster.DOM.toggleAttributeToken();
241
231
  * </script>
242
232
  * ```
@@ -245,7 +235,7 @@ function getLinkedObjects(element, symbol) {
245
235
  *
246
236
  * ```
247
237
  * <script type="module">
248
- * import {toggleAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
238
+ * import {toggleAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
249
239
  * toggleAttributeToken();
250
240
  * </script>
251
241
  * ```
@@ -280,7 +270,7 @@ function toggleAttributeToken(element, key, token) {
280
270
  *
281
271
  * ```
282
272
  * <script type="module">
283
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
273
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
284
274
  * Monster.DOM.addAttributeToken();
285
275
  * </script>
286
276
  * ```
@@ -289,7 +279,7 @@ function toggleAttributeToken(element, key, token) {
289
279
  *
290
280
  * ```
291
281
  * <script type="module">
292
- * import {addAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
282
+ * import {addAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
293
283
  * addAttributeToken();
294
284
  * </script>
295
285
  * ```
@@ -326,7 +316,7 @@ function addAttributeToken(element, key, token) {
326
316
  *
327
317
  * ```
328
318
  * <script type="module">
329
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
319
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
330
320
  * Monster.DOM.removeAttributeToken();
331
321
  * </script>
332
322
  * ```
@@ -335,7 +325,7 @@ function addAttributeToken(element, key, token) {
335
325
  *
336
326
  * ```
337
327
  * <script type="module">
338
- * import {removeAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
328
+ * import {removeAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
339
329
  * removeAttributeToken();
340
330
  * </script>
341
331
  * ```
@@ -371,7 +361,7 @@ function removeAttributeToken(element, key, token) {
371
361
  *
372
362
  * ```
373
363
  * <script type="module">
374
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
364
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
375
365
  * Monster.DOM.containsAttributeToken();
376
366
  * </script>
377
367
  * ```
@@ -380,7 +370,7 @@ function removeAttributeToken(element, key, token) {
380
370
  *
381
371
  * ```
382
372
  * <script type="module">
383
- * import {containsAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
373
+ * import {containsAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
384
374
  * containsAttributeToken();
385
375
  * </script>
386
376
  * ```
@@ -413,7 +403,7 @@ function containsAttributeToken(element, key, token) {
413
403
  *
414
404
  * ```
415
405
  * <script type="module">
416
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
406
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
417
407
  * Monster.DOM.replaceAttributeToken();
418
408
  * </script>
419
409
  * ```
@@ -422,7 +412,7 @@ function containsAttributeToken(element, key, token) {
422
412
  *
423
413
  * ```
424
414
  * <script type="module">
425
- * import {replaceAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
415
+ * import {replaceAttributeToken} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
426
416
  * replaceAttributeToken();
427
417
  * </script>
428
418
  * ```
@@ -458,7 +448,7 @@ function replaceAttributeToken(element, key, from, to) {
458
448
  *
459
449
  * ```
460
450
  * <script type="module">
461
- * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
451
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
462
452
  * Monster.DOM.clearAttributeTokens();
463
453
  * </script>
464
454
  * ```
@@ -467,13 +457,13 @@ function replaceAttributeToken(element, key, from, to) {
467
457
  *
468
458
  * ```
469
459
  * <script type="module">
470
- * import {clearAttributeTokens} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.12.0/dist/modules/dom/attributes.js';
460
+ * import {clearAttributeTokens} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
471
461
  * clearAttributeTokens();
472
462
  * </script>
473
463
  * ```
474
464
  *
475
465
  * @since 1.9.0
476
- * @copyright schukai GmbH
466
+ * @copyright schukai GmbH
477
467
  * @memberOf Monster/DOM
478
468
  * @param {HTMLElement} element
479
469
  * @param {string} key
@@ -492,13 +482,67 @@ function clearAttributeTokens(element, key) {
492
482
  return element
493
483
  }
494
484
 
485
+ /**
486
+ * You can call the method via the monster namespace `new Monster.DOM.findClosestByAttribute()`.
487
+ *
488
+ * ```
489
+ * <script type="module">
490
+ * import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
491
+ * Monster.DOM.findClosestByAttribute();
492
+ * </script>
493
+ * ```
494
+ *
495
+ * Alternatively, you can also integrate this function individually.
496
+ *
497
+ * ```
498
+ * <script type="module">
499
+ * import {clearAttributeTokens} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.0/dist/modules/dom/attributes.js';
500
+ * findClosestByAttribute();
501
+ * </script>
502
+ * ```
503
+ *
504
+ * @since 1.14.0
505
+ * @copyright schukai GmbH
506
+ * @memberOf Monster/DOM
507
+ * @param {HTMLElement} element
508
+ * @param {string} key
509
+ * @return {HTMLElement|undefined}
510
+ * @throws {TypeError} value is not a string
511
+ * @throws {TypeError} value is not an instance of HTMLElement
512
+ */
513
+
514
+ /**
515
+ *
516
+ * @since 1.14.0
517
+ * @param {HTMLElement} element
518
+ * @param {string} key
519
+ * @param {string|undefined} value
520
+ * @return {HTMLElement|undefined}
521
+ */
522
+ function findClosestByAttribute(element, key, value) {
523
+ validateInstance(element, getGlobalFunction('HTMLElement'));
524
+
525
+ if (element.hasAttribute(key) && element.getAttribute(key) === value) {
526
+ return element;
527
+ }
528
+
529
+ let selector = validateString(key);
530
+ if (value !== undefined) selector += "=" + validateString(value);
531
+ let result = element.closest('[' + selector + ']');
532
+ if (result instanceof HTMLElement) {
533
+ return result;
534
+ }
535
+ return undefined;
536
+ }
495
537
 
496
- Monster.assignToNamespace('Monster.DOM', getLinkedObjects, addToObjectLink, removeObjectLink, hasObjectLink, clearAttributeTokens, replaceAttributeToken, containsAttributeToken, removeAttributeToken, addAttributeToken, toggleAttributeToken);
538
+ // exports
539
+ assignToNamespace('Monster.DOM', getLinkedObjects, addToObjectLink, removeObjectLink, findClosestByAttribute, hasObjectLink, clearAttributeTokens, replaceAttributeToken, containsAttributeToken, removeAttributeToken, addAttributeToken, toggleAttributeToken);
497
540
  export {
498
541
  Monster,
499
542
  addToObjectLink,
500
543
  removeObjectLink,
501
544
  hasObjectLink,
545
+ findClosestByAttribute,
502
546
  clearAttributeTokens,
503
547
  replaceAttributeToken,
504
548
  containsAttributeToken,
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
- import {Monster} from "../namespace.js";
4
-
3
+ import {Monster, assignToNamespace} from '../namespace.js';
5
4
  /**
6
5
  * @author schukai GmbH
7
6
  */
@@ -86,23 +85,23 @@ const ATTRIBUTE_UPDATER_BIND = ATTRIBUTE_PREFIX + 'bind';
86
85
  /**
87
86
  * @memberOf Monster/DOM
88
87
  * @type {string}
89
- * @since 1.9.0
88
+ * @since 1.14.0
90
89
  */
91
- const ATTRIBUTE_OBJECTLINK = ATTRIBUTE_PREFIX + 'objectlink';
90
+ const ATTRIBUTE_ROLE = ATTRIBUTE_PREFIX + 'role';
92
91
 
93
92
  /**
94
93
  * @memberOf Monster/DOM
95
94
  * @type {string}
96
- * @since 1.10.0
95
+ * @since 1.9.0
97
96
  */
98
- const OBJECTLINK_KEY_UPDATER = 'monsterUpdater';
97
+ const ATTRIBUTE_OBJECTLINK = ATTRIBUTE_PREFIX + 'objectlink';
99
98
 
100
99
  /**
101
100
  * @memberOf Monster/DOM
102
101
  * @type {string}
103
102
  * @since 1.10.0
104
103
  */
105
- const OBJECTLINK_KEY_OPTIONS = 'monsterOptions';
104
+ const OBJECTLINK_KEY_UPDATER = 'monsterUpdater';
106
105
 
107
106
 
108
107
  export {
@@ -111,6 +110,7 @@ export {
111
110
  ATTRIBUTE_OPTIONS,
112
111
  DEFAULT_THEME,
113
112
  ATTRIBUTE_THEME_PREFIX,
113
+ ATTRIBUTE_ROLE,
114
114
  ATTRIBUTE_THEME_NAME,
115
115
  ATTRIBUTE_UPDATER_ATTRIBUTES,
116
116
  ATTRIBUTE_UPDATER_REPLACE,
@@ -119,6 +119,5 @@ export {
119
119
  ATTRIBUTE_UPDATER_REMOVE,
120
120
  ATTRIBUTE_UPDATER_BIND,
121
121
  ATTRIBUTE_OBJECTLINK,
122
- OBJECTLINK_KEY_UPDATER,
123
- OBJECTLINK_KEY_OPTIONS
122
+ OBJECTLINK_KEY_UPDATER
124
123
  }