@schukai/monster 1.13.0 → 1.15.2

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