@schukai/monster 1.24.0 → 1.27.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. package/CHANGELOG +47 -0
  2. package/README.md +4 -4
  3. package/dist/modules/constants.js +2 -2
  4. package/dist/modules/constraints/abstract.js +1 -1
  5. package/dist/modules/constraints/abstractoperator.js +1 -1
  6. package/dist/modules/constraints/andoperator.js +1 -1
  7. package/dist/modules/constraints/invalid.js +1 -1
  8. package/dist/modules/constraints/isarray.js +1 -1
  9. package/dist/modules/constraints/isobject.js +1 -1
  10. package/dist/modules/constraints/namespace.js +1 -1
  11. package/dist/modules/constraints/oroperator.js +1 -1
  12. package/dist/modules/constraints/valid.js +1 -1
  13. package/dist/modules/data/buildmap.js +2 -2
  14. package/dist/modules/data/buildtree.js +2 -0
  15. package/dist/modules/data/datasource/namespace.js +1 -1
  16. package/dist/modules/data/datasource/restapi/writeerror.js +1 -1
  17. package/dist/modules/data/datasource/restapi.js +1 -1
  18. package/dist/modules/data/datasource/storage/localstorage.js +1 -1
  19. package/dist/modules/data/datasource/storage/namespace.js +1 -1
  20. package/dist/modules/data/datasource/storage/sessionstorage.js +1 -1
  21. package/dist/modules/data/datasource/storage.js +1 -1
  22. package/dist/modules/data/datasource.js +1 -1
  23. package/dist/modules/data/diff.js +1 -1
  24. package/dist/modules/data/extend.js +1 -1
  25. package/dist/modules/data/namespace.js +1 -1
  26. package/dist/modules/data/pathfinder.js +1 -1
  27. package/dist/modules/data/pipe.js +1 -1
  28. package/dist/modules/data/transformer.js +2 -2
  29. package/dist/modules/dom/assembler.js +1 -1
  30. package/dist/modules/dom/attributes.js +2 -2
  31. package/dist/modules/dom/constants.js +2 -2
  32. package/dist/modules/dom/customcontrol.js +1 -1
  33. package/dist/modules/dom/customelement.js +1 -1
  34. package/dist/modules/dom/events.js +1 -1
  35. package/dist/modules/dom/focusmanager.js +2 -0
  36. package/dist/modules/dom/locale.js +1 -1
  37. package/dist/modules/dom/namespace.js +1 -1
  38. package/dist/modules/dom/resource/data.js +2 -0
  39. package/dist/modules/dom/resource/link/stylesheet.js +2 -0
  40. package/dist/modules/dom/resource/link.js +2 -0
  41. package/dist/modules/dom/resource/script.js +2 -0
  42. package/dist/modules/dom/resource.js +2 -0
  43. package/dist/modules/dom/resourcemanager.js +2 -0
  44. package/dist/modules/dom/template.js +2 -2
  45. package/dist/modules/dom/theme.js +1 -1
  46. package/dist/modules/dom/updater.js +2 -2
  47. package/dist/modules/dom/util.js +1 -1
  48. package/dist/modules/dom/worker/factory.js +2 -0
  49. package/dist/modules/i18n/formatter.js +2 -0
  50. package/dist/modules/i18n/locale.js +1 -1
  51. package/dist/modules/i18n/namespace.js +1 -1
  52. package/dist/modules/i18n/provider.js +1 -1
  53. package/dist/modules/i18n/providers/fetch.js +1 -1
  54. package/dist/modules/i18n/providers/namespace.js +1 -1
  55. package/dist/modules/i18n/translations.js +1 -1
  56. package/dist/modules/logging/handler/console.js +1 -1
  57. package/dist/modules/logging/handler/namespace.js +1 -1
  58. package/dist/modules/logging/handler.js +1 -1
  59. package/dist/modules/logging/logentry.js +1 -1
  60. package/dist/modules/logging/logger.js +1 -1
  61. package/dist/modules/logging/namespace.js +1 -1
  62. package/dist/modules/math/namespace.js +1 -1
  63. package/dist/modules/math/random.js +2 -2
  64. package/dist/modules/monster.js +1 -1
  65. package/dist/modules/namespace.js +1 -1
  66. package/dist/modules/text/formatter.js +2 -2
  67. package/dist/modules/text/namespace.js +1 -1
  68. package/dist/modules/types/base.js +1 -1
  69. package/dist/modules/types/basewithoptions.js +1 -1
  70. package/dist/modules/types/binary.js +1 -1
  71. package/dist/modules/types/dataurl.js +1 -1
  72. package/dist/modules/types/global.js +1 -1
  73. package/dist/modules/types/id.js +1 -1
  74. package/dist/modules/types/is.js +2 -2
  75. package/dist/modules/types/mediatype.js +1 -1
  76. package/dist/modules/types/namespace.js +1 -1
  77. package/dist/modules/types/node.js +2 -0
  78. package/dist/modules/types/nodelist.js +2 -0
  79. package/dist/modules/types/noderecursiveiterator.js +2 -0
  80. package/dist/modules/types/observer.js +1 -1
  81. package/dist/modules/types/observerlist.js +1 -1
  82. package/dist/modules/types/proxyobserver.js +1 -1
  83. package/dist/modules/types/queue.js +1 -1
  84. package/dist/modules/types/randomid.js +1 -1
  85. package/dist/modules/types/regex.js +2 -0
  86. package/dist/modules/types/stack.js +1 -1
  87. package/dist/modules/types/tokenlist.js +1 -1
  88. package/dist/modules/types/typeof.js +1 -1
  89. package/dist/modules/types/uniquequeue.js +1 -1
  90. package/dist/modules/types/uuid.js +2 -0
  91. package/dist/modules/types/validate.js +1 -1
  92. package/dist/modules/types/version.js +2 -2
  93. package/dist/modules/util/clone.js +1 -1
  94. package/dist/modules/util/comparator.js +1 -1
  95. package/dist/modules/util/freeze.js +1 -1
  96. package/dist/modules/util/namespace.js +1 -1
  97. package/dist/modules/util/processing.js +1 -1
  98. package/dist/modules/util/trimspaces.js +1 -1
  99. package/dist/monster.dev.js +1528 -770
  100. package/dist/monster.dev.js.map +1 -1
  101. package/dist/monster.js +2 -2
  102. package/package.json +13 -2
  103. package/source/constants.js +11 -2
  104. package/source/constraints/abstract.js +5 -0
  105. package/source/constraints/abstractoperator.js +5 -0
  106. package/source/constraints/andoperator.js +10 -5
  107. package/source/constraints/invalid.js +8 -3
  108. package/source/constraints/isarray.js +9 -4
  109. package/source/constraints/isobject.js +8 -3
  110. package/source/constraints/oroperator.js +10 -5
  111. package/source/constraints/valid.js +8 -3
  112. package/source/data/buildmap.js +25 -9
  113. package/source/data/buildtree.js +95 -0
  114. package/source/data/datasource/restapi.js +3 -3
  115. package/source/data/datasource/storage/localstorage.js +2 -2
  116. package/source/data/datasource/storage/sessionstorage.js +2 -2
  117. package/source/data/datasource/storage.js +3 -3
  118. package/source/data/datasource.js +3 -3
  119. package/source/data/diff.js +3 -3
  120. package/source/data/extend.js +2 -2
  121. package/source/data/pathfinder.js +4 -4
  122. package/source/data/pipe.js +3 -3
  123. package/source/data/transformer.js +7 -5
  124. package/source/dom/assembler.js +2 -2
  125. package/source/dom/attributes.js +111 -28
  126. package/source/dom/constants.js +287 -10
  127. package/source/dom/customcontrol.js +1 -1
  128. package/source/dom/customelement.js +1 -1
  129. package/source/dom/events.js +6 -7
  130. package/source/dom/focusmanager.js +250 -0
  131. package/source/dom/locale.js +10 -5
  132. package/source/dom/resource/data.js +170 -0
  133. package/source/dom/resource/link/stylesheet.js +54 -0
  134. package/source/dom/resource/link.js +125 -0
  135. package/source/dom/resource/script.js +112 -0
  136. package/source/dom/resource.js +268 -0
  137. package/source/dom/resourcemanager.js +214 -0
  138. package/source/dom/template.js +86 -16
  139. package/source/dom/theme.js +3 -3
  140. package/source/dom/updater.js +138 -90
  141. package/source/dom/util.js +6 -6
  142. package/source/dom/worker/factory.js +134 -0
  143. package/source/i18n/formatter.js +140 -0
  144. package/source/i18n/locale.js +6 -4
  145. package/source/i18n/provider.js +2 -2
  146. package/source/i18n/providers/fetch.js +18 -3
  147. package/source/i18n/translations.js +18 -9
  148. package/source/logging/handler/console.js +2 -2
  149. package/source/logging/handler.js +2 -2
  150. package/source/logging/logentry.js +2 -2
  151. package/source/logging/logger.js +2 -2
  152. package/source/math/random.js +9 -5
  153. package/source/namespace.js +1 -1
  154. package/source/text/formatter.js +190 -48
  155. package/source/types/base.js +4 -4
  156. package/source/types/basewithoptions.js +2 -2
  157. package/source/types/binary.js +4 -4
  158. package/source/types/dataurl.js +4 -4
  159. package/source/types/global.js +4 -4
  160. package/source/types/id.js +6 -3
  161. package/source/types/is.js +103 -85
  162. package/source/types/mediatype.js +4 -4
  163. package/source/types/node.js +179 -0
  164. package/source/types/nodelist.js +125 -0
  165. package/source/types/noderecursiveiterator.js +126 -0
  166. package/source/types/observer.js +3 -3
  167. package/source/types/observerlist.js +2 -2
  168. package/source/types/proxyobserver.js +5 -5
  169. package/source/types/queue.js +4 -4
  170. package/source/types/randomid.js +2 -2
  171. package/source/types/regex.js +49 -0
  172. package/source/types/stack.js +2 -2
  173. package/source/types/tokenlist.js +2 -2
  174. package/source/types/typeof.js +3 -3
  175. package/source/types/uniquequeue.js +2 -2
  176. package/source/types/uuid.js +102 -0
  177. package/source/types/validate.js +20 -20
  178. package/source/types/version.js +6 -6
  179. package/source/util/clone.js +2 -2
  180. package/source/util/comparator.js +4 -4
  181. package/source/util/freeze.js +5 -5
  182. package/source/util/processing.js +3 -3
  183. package/source/util/trimspaces.js +3 -3
  184. package/test/cases/data/buildtree.js +149 -0
  185. package/test/cases/data/datasource/restapi.js +1 -1
  186. package/test/cases/data/transformer.js +2 -0
  187. package/test/cases/dom/attributes.js +46 -19
  188. package/test/cases/dom/customelement.js +0 -3
  189. package/test/cases/dom/focusmanager.js +111 -0
  190. package/test/cases/dom/locale.js +1 -4
  191. package/test/cases/dom/resource/data.js +129 -0
  192. package/test/cases/dom/resource/link/stylesheet.js +101 -0
  193. package/test/cases/dom/resource/link.js +101 -0
  194. package/test/cases/dom/resource/script.js +115 -0
  195. package/test/cases/dom/resourcemanager.js +118 -0
  196. package/test/cases/dom/template.js +72 -14
  197. package/test/cases/dom/updater.js +102 -75
  198. package/test/cases/dom/worker/factory.js +63 -0
  199. package/test/cases/i18n/formatter.js +66 -0
  200. package/test/cases/monster.js +1 -1
  201. package/test/cases/text/formatter.js +36 -5
  202. package/test/cases/types/node.js +196 -0
  203. package/test/cases/types/nodelist.js +64 -0
  204. package/test/cases/types/noderecursiveiterator.js +54 -0
  205. package/test/cases/types/regex.js +32 -0
  206. package/test/cases/types/uuid.js +42 -0
  207. package/test/cases/util/freeze.js +30 -4
  208. package/test/util/cleanupdom.js +48 -0
  209. package/test/util/jsdom.js +22 -9
  210. package/test/web/import.js +14 -0
  211. package/test/web/monster-dev.html +3 -3
  212. package/test/web/monster.html +2 -2
  213. package/test/web/test.html +3 -3
  214. package/test/web/tests.js +7 -7
@@ -0,0 +1,196 @@
1
+ 'use strict';
2
+
3
+ import {expect} from "chai"
4
+ import {Node} from "../../../source/types/node.js";
5
+ import {NodeList} from "../../../source/types/nodelist.js";
6
+ import {NodeRecursiveIterator} from "../../../source/types/noderecursiveiterator.js";
7
+
8
+ describe('NodeList', function () {
9
+ describe('#constructor', function () {
10
+ it('should create an empty NodeList', function () {
11
+ let nodeList = new NodeList();
12
+
13
+ expect(nodeList.size).to.equal(0);
14
+ });
15
+
16
+ it('should create a NodeList from an array', function () {
17
+ let nodeList = new NodeList([
18
+ new Node('div'),
19
+ new Node('div'),
20
+ new Node('div')
21
+ ]);
22
+
23
+ expect(nodeList.size).to.equal(3);
24
+ });
25
+
26
+ it('should create a NodeList from a NodeList', function () {
27
+ let nodeList = new NodeList([
28
+ new Node('div'),
29
+ new Node('div'),
30
+ new Node('div')
31
+ ]);
32
+
33
+ let nodeList2 = new NodeList(nodeList);
34
+
35
+ expect(nodeList2.size).to.equal(3);
36
+ });
37
+ });
38
+
39
+ it('create NodeList', function () {
40
+ expect(new NodeList()).is.instanceof(NodeList);
41
+ })
42
+
43
+ it('add Node', function () {
44
+ expect(new NodeList().add(new Node())).to.be.instanceof(NodeList);
45
+ })
46
+
47
+ it('remove Node', function () {
48
+ expect(new NodeList().remove(new Node())).to.be.instanceof(NodeList);
49
+ })
50
+
51
+ it('has unknown Node', function () {
52
+ expect(new NodeList().has(new Node)).to.be.false;
53
+ })
54
+
55
+ it('has added Node', function () {
56
+ const n = new Node;
57
+ expect(new NodeList().add(n).has(n)).to.be.true;
58
+ })
59
+
60
+ it('throw exception', function () {
61
+ expect(() => new NodeList().add(1)).to.throw(Error);
62
+ })
63
+
64
+ it('check level', function () {
65
+
66
+ const root = new Node('root');
67
+
68
+ const n1 = new Node('n1');
69
+ const n2 = new Node('n2');
70
+ const n3 = new Node('n3');
71
+ const n4 = new Node('n4');
72
+
73
+ const n11 = new Node('n11');
74
+ const n12 = new Node('n12');
75
+ const n13 = new Node('n13');
76
+
77
+ const n21 = new Node('n21');
78
+ const n22 = new Node('n22');
79
+ const n23 = new Node('n23');
80
+
81
+ const n41 = new Node('n41');
82
+ const n42 = new Node('n42');
83
+
84
+ const n411 = new Node('n411');
85
+ const n412 = new Node('n412');
86
+ const n413 = new Node('n413');
87
+
88
+ const n4121 = new Node('n4121');
89
+
90
+ root.appendChild(n1).appendChild(n2).appendChild(n3).appendChild(n4);
91
+ n1.appendChild(n11).appendChild(n12).appendChild(n13);
92
+ n2.appendChild(n21).appendChild(n22).appendChild(n23);
93
+ n4.appendChild(n41).appendChild(n42);
94
+ n41.appendChild(n411).appendChild(n412).appendChild(n413);
95
+ n412.appendChild(n4121);
96
+
97
+ let iterator = new NodeRecursiveIterator(root);
98
+
99
+ let result = [];
100
+ for (const n of iterator) {
101
+ expect(n).to.be.an.instanceof(Node);
102
+ result.push(n.value + ":" + n.level);
103
+ }
104
+
105
+
106
+ expect(result).to.deep.equal([
107
+ 'root:0',
108
+ 'n1:1',
109
+ 'n11:2',
110
+ 'n12:2',
111
+ 'n13:2',
112
+ 'n2:1',
113
+ 'n21:2',
114
+ 'n22:2',
115
+ 'n23:2',
116
+ 'n3:1',
117
+ 'n4:1',
118
+ 'n41:2',
119
+ 'n411:3',
120
+ 'n412:3',
121
+ 'n4121:4',
122
+ 'n413:3',
123
+ 'n42:2'
124
+
125
+ ]);
126
+
127
+ n4121.appendChild(new Node('n41211'));
128
+
129
+ iterator = new NodeRecursiveIterator(root);
130
+ result = [];
131
+ for (const n of iterator) {
132
+ expect(n).to.be.an.instanceof(Node);
133
+ result.push(n.value + ":" + n.level);
134
+ }
135
+
136
+ expect(result).to.deep.equal([
137
+ 'root:0',
138
+ 'n1:1',
139
+ 'n11:2',
140
+ 'n12:2',
141
+ 'n13:2',
142
+ 'n2:1',
143
+ 'n21:2',
144
+ 'n22:2',
145
+ 'n23:2',
146
+ 'n3:1',
147
+ 'n4:1',
148
+ 'n41:2',
149
+ 'n411:3',
150
+ 'n412:3',
151
+ 'n4121:4',
152
+ 'n41211:5',
153
+ 'n413:3',
154
+ 'n42:2'
155
+
156
+ ]);
157
+
158
+
159
+ const bb = new Node('bb') // big bang
160
+
161
+ bb.appendChild(root);
162
+ iterator = new NodeRecursiveIterator(bb);
163
+
164
+ result = [];
165
+ for (const n of iterator) {
166
+ expect(n).to.be.an.instanceof(Node);
167
+ result.push(n.value + ":" + n.level);
168
+ }
169
+
170
+ expect(result).to.deep.equal([
171
+ 'bb:0',
172
+ 'root:1',
173
+ 'n1:2',
174
+ 'n11:3',
175
+ 'n12:3',
176
+ 'n13:3',
177
+ 'n2:2',
178
+ 'n21:3',
179
+ 'n22:3',
180
+ 'n23:3',
181
+ 'n3:2',
182
+ 'n4:2',
183
+ 'n41:3',
184
+ 'n411:4',
185
+ 'n412:4',
186
+ 'n4121:5',
187
+ 'n41211:6',
188
+ 'n413:4',
189
+ 'n42:3'
190
+
191
+ ]);
192
+
193
+ })
194
+
195
+
196
+ });
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+
3
+ import {expect} from "chai"
4
+ import {Node} from "../../../source/types/node.js";
5
+ import {NodeList} from "../../../source/types/nodelist.js";
6
+
7
+ describe('NodeList', function () {
8
+ describe('#constructor', function () {
9
+ it('should create an empty NodeList', function () {
10
+ let nodeList = new NodeList();
11
+
12
+ expect(nodeList.size).to.equal(0);
13
+ });
14
+
15
+ it('should create a NodeList from an array', function () {
16
+ let nodeList = new NodeList([
17
+ new Node('div'),
18
+ new Node('div'),
19
+ new Node('div')
20
+ ]);
21
+
22
+ expect(nodeList.size).to.equal(3);
23
+ });
24
+
25
+ it('should create a NodeList from a NodeList', function () {
26
+ let nodeList = new NodeList([
27
+ new Node('div'),
28
+ new Node('div'),
29
+ new Node('div')
30
+ ]);
31
+
32
+ let nodeList2 = new NodeList(nodeList);
33
+
34
+ expect(nodeList2.size).to.equal(3);
35
+ });
36
+ });
37
+
38
+ it('create NodeList', function () {
39
+ expect(new NodeList()).is.instanceof(NodeList);
40
+ })
41
+
42
+ it('add Node', function () {
43
+ expect(new NodeList().add(new Node())).to.be.instanceof(NodeList);
44
+ })
45
+
46
+ it('remove Node', function () {
47
+ expect(new NodeList().remove(new Node())).to.be.instanceof(NodeList);
48
+ })
49
+
50
+ it('has unknown Node', function () {
51
+ expect(new NodeList().has(new Node)).to.be.false;
52
+ })
53
+
54
+ it('has added Node', function () {
55
+ const n = new Node;
56
+ expect(new NodeList().add(n).has(n)).to.be.true;
57
+ })
58
+
59
+ it('throw exception', function () {
60
+ expect(() => new NodeList().add(1)).to.throw(Error);
61
+ })
62
+
63
+
64
+ });
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ import {expect} from "chai"
4
+ import {Node} from "../../../source/types/node.js";
5
+ import {NodeRecursiveIterator} from "../../../source/types/noderecursiveiterator.js";
6
+
7
+ describe('NodeRecursiveIterator', function () {
8
+
9
+ it('should throw exeption', function () {
10
+ expect(() => new NodeRecursiveIterator()).to.throw(Error)
11
+ });
12
+ it('should be a function', function () {
13
+ expect(NodeRecursiveIterator).to.be.a('function');
14
+ });
15
+
16
+ it('should be a constructor', function () {
17
+ expect(new NodeRecursiveIterator(new Node)).to.be.an.instanceof(NodeRecursiveIterator);
18
+ });
19
+
20
+ /**
21
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
22
+ */
23
+ it('undefined should not result in undefined node', function () {
24
+ const iterator = new NodeRecursiveIterator(new Node);
25
+
26
+ const result = [];
27
+ for (const n of iterator) {
28
+ expect(n).to.be.an.instanceof(Node);
29
+ result.push(n.value);
30
+ }
31
+
32
+ expect(result).to.deep.equal([undefined]);
33
+
34
+ });
35
+
36
+ it('should iterate', function () {
37
+ const node =
38
+ new Node('1')
39
+ node.appendChild(
40
+ (new Node('2')).appendChild(new Node('2.1')).appendChild(new Node('2.2')).appendChild(new Node('2.3'))).appendChild(new Node('3')).appendChild(new Node('4').appendChild(new Node('4.1')).appendChild(new Node('4.2')));
41
+
42
+ const iterator = new NodeRecursiveIterator(node);
43
+
44
+ const result = [];
45
+ for (const n of iterator) {
46
+ expect(n).to.be.an.instanceof(Node);
47
+ result.push(n.value);
48
+ }
49
+
50
+ expect(result).to.deep.equal(['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']);
51
+
52
+ });
53
+
54
+ });
@@ -0,0 +1,32 @@
1
+ import * as Crypto from "@peculiar/webcrypto";
2
+
3
+ import {expect} from "chai"
4
+ import {escapeString} from "../../../source/types/regex.js"
5
+
6
+ if (!global['crypto']) {
7
+ global['crypto'] = new Crypto.Crypto();
8
+ }
9
+
10
+ describe('escapeString', function () {
11
+
12
+
13
+ [
14
+ ['test1', 'test1'],
15
+ ['${', '\\$\\{'],
16
+ ['i18n{', 'i18n\\{'],
17
+ ['//', '//'],
18
+ ['\\', '\\\\'],
19
+
20
+ ].forEach(function (data) {
21
+
22
+ let a = data.shift()
23
+ let b = data.shift()
24
+
25
+ it('escapeString(' + a + ') should return ' + b, function () {
26
+ expect(escapeString(a)).is.equal(b)
27
+ });
28
+ });
29
+
30
+
31
+ });
32
+
@@ -0,0 +1,42 @@
1
+ import * as Crypto from "@peculiar/webcrypto";
2
+ import {expect} from "chai"
3
+ import {UUID} from "../../../source/types/uuid.js";
4
+
5
+ if (!global['crypto']) {
6
+ global['crypto'] = new Crypto.Crypto();
7
+ }
8
+
9
+
10
+ describe('UUID', function () {
11
+
12
+ describe('.toString()', function () {
13
+ let uuid = new UUID()
14
+ let result = uuid.toString();
15
+
16
+ it('should return a string', function () {
17
+ expect(result).is.a('string')
18
+ expect(result.length).is.equal(36)
19
+ });
20
+
21
+ it('test format', function (done) {
22
+
23
+ const regexExp = /^[A-F\d]{8}-[A-F\d]{4}-4[A-F\d]{3}-[89AB][A-F\d]{3}-[A-F\d]{12}$/i;
24
+
25
+ for (let i = 0; i < 2000; i++) {
26
+ const u = new UUID().toString();
27
+ const r = regexExp.test(u);
28
+
29
+ if (r !== true) {
30
+ done('no uuid ' + u + ' => ' + r);
31
+ return;
32
+ }
33
+ }
34
+
35
+ done();
36
+
37
+ });
38
+
39
+ });
40
+
41
+ });
42
+
@@ -10,13 +10,39 @@ describe('deepFreeze', function () {
10
10
 
11
11
  let obj1 = {
12
12
  a: {
13
- b: {}
13
+ b: {
14
+ c:1
15
+ }
14
16
  }
15
17
  };
16
18
 
17
- expect(() => obj1.a.b.c = 1).to.not.throw(TypeError);
18
- const obj2 = deepFreeze(obj1);
19
- expect(() => obj2.a.b.c = 1).to.throw(TypeError);
19
+ let obj2 = {
20
+ a: {
21
+ b: {
22
+ c:2
23
+ }
24
+ }
25
+ };
26
+
27
+ expect(obj2).to.not.eql(obj1)
28
+ obj1.a.b.c = 2;
29
+ expect(obj2).to.eql(obj1);
30
+
31
+ const obj1Freezed = deepFreeze(obj1);
32
+
33
+ expect(obj2).to.eql(obj1Freezed);
34
+
35
+ try {
36
+ // https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
37
+ // no change to the object, exception depends on mode (strict ES 2015, etc)
38
+ obj1Freezed.a.b.c = 3
39
+ } catch (_) {
40
+
41
+ }
42
+
43
+ expect(obj2).to.eql(obj1Freezed);
44
+
45
+
20
46
  });
21
47
 
22
48
  });
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+
4
+ let addedNodes, mutationobserver;
5
+
6
+ function init() {
7
+
8
+ addedNodes = [];
9
+ mutationobserver = new MutationObserver(function (mutations) {
10
+ mutations.forEach(function (mutation) {
11
+ if (mutation.type === 'childList' && mutation.removedNodes) {
12
+
13
+ mutation.addedNodes.forEach((n) => {
14
+ if (n instanceof HTMLElement) {
15
+ addedNodes.push(n);
16
+ }
17
+ })
18
+ }
19
+
20
+ });
21
+ });
22
+
23
+
24
+ }
25
+
26
+
27
+ /**
28
+ *
29
+ */
30
+ export function initMutationObserverForTesting() {
31
+
32
+ if (mutationobserver === undefined) {
33
+ init()
34
+ }
35
+
36
+ mutationobserver.observe(document.querySelector('head'), {childList: true});
37
+ }
38
+
39
+ /**
40
+ *
41
+ */
42
+ export function cleanupDOMFromTesting() {
43
+ mutationobserver.disconnect();
44
+
45
+ for (const n of addedNodes) {
46
+ n.remove();
47
+ }
48
+ }
@@ -1,29 +1,39 @@
1
1
  'use strict';
2
2
 
3
+ import {extend} from "../../source/data/extend.js";
3
4
  import {getGlobal} from "../../source/types/global.js";
4
5
 
6
+ export const isBrowser = new Function("try {return this===window;}catch(e){ return false;}");
7
+
8
+ export const isNode = new Function("try {return this===global;}catch(e){return false;}");
9
+
10
+
5
11
  /**
6
12
  * this helper function creates the dom stack in the node environment
7
13
  *
8
14
  * @return {Promise<unknown>|Promise<void>}
9
15
  */
10
- function initJSDOM() {
16
+ function initJSDOM(options) {
11
17
  if (typeof window === "object" && window['DOMParser']) return Promise.resolve();
12
18
 
13
19
  const g = getGlobal();
14
20
 
21
+ options = extend({}, {
22
+ pretendToBeVisual: true,
23
+ contentType: "text/html",
24
+ includeNodeLocations: true,
25
+ storageQuota: 10000000,
26
+ runScripts: "dangerously",
27
+ resources: "usable"
28
+ }, options||{})
29
+
15
30
  return import("jsdom").then(({JSDOM}) => {
16
31
  const {window} = new JSDOM(`<html>
17
32
  <head>
18
33
  </head>
19
34
  <body>
20
35
  <div id="mocks"></div>
21
- </body>`, {
22
- pretendToBeVisual: true,
23
- contentType: "text/html",
24
- includeNodeLocations: true,
25
- storageQuota: 10000000
26
- });
36
+ </body>`, options);
27
37
 
28
38
  g['window'] = window;
29
39
 
@@ -35,6 +45,7 @@ function initJSDOM() {
35
45
  'HTMLCollection',
36
46
  'NodeList',
37
47
  'ElementInternals',
48
+ 'HTMLDocument',
38
49
  'HTMLFormElement',
39
50
  'HTMLInputElement',
40
51
  'HTMLSelectElement',
@@ -44,7 +55,6 @@ function initJSDOM() {
44
55
  'Node',
45
56
  'ShadowRoot',
46
57
  'Event',
47
- 'fetch',
48
58
  'CustomEvent',
49
59
  'Element',
50
60
  'HTMLElement',
@@ -59,8 +69,11 @@ function initJSDOM() {
59
69
  'NodeFilter',
60
70
  'navigator',
61
71
  'InputEvent',
72
+ 'Blob',
62
73
  'CustomEvent'
63
- ].forEach(key => (g[key] = window[key]));
74
+ ].forEach(key => {
75
+ g[key] = window[key]
76
+ });
64
77
 
65
78
  resolve();
66
79
  })
@@ -5,22 +5,31 @@ import "../cases/logging/handler.js";
5
5
  import "../cases/logging/logentry.js";
6
6
  import "../cases/logging/handler/console.js";
7
7
  import "../cases/text/formatter.js";
8
+ import "../cases/dom/resource/script.js";
9
+ import "../cases/dom/resource/data.js";
10
+ import "../cases/dom/resource/link/stylesheet.js";
11
+ import "../cases/dom/resource/link.js";
8
12
  import "../cases/dom/updater.js";
9
13
  import "../cases/dom/attributes.js";
10
14
  import "../cases/dom/template.js";
11
15
  import "../cases/dom/util.js";
16
+ import "../cases/dom/resourcemanager.js";
12
17
  import "../cases/dom/locale.js";
13
18
  import "../cases/dom/customcontrol.js";
14
19
  import "../cases/dom/assembler.js";
15
20
  import "../cases/dom/theme.js";
21
+ import "../cases/dom/worker/factory.js";
22
+ import "../cases/dom/focusmanager.js";
16
23
  import "../cases/dom/events.js";
17
24
  import "../cases/dom/customelement.js";
25
+ import "../cases/i18n/formatter.js";
18
26
  import "../cases/i18n/providers/fetch.js";
19
27
  import "../cases/i18n/translations.js";
20
28
  import "../cases/i18n/locale.js";
21
29
  import "../cases/i18n/provider.js";
22
30
  import "../cases/types/queue.js";
23
31
  import "../cases/types/binary.js";
32
+ import "../cases/types/regex.js";
24
33
  import "../cases/types/observer.js";
25
34
  import "../cases/types/global.js";
26
35
  import "../cases/types/observerlist.js";
@@ -28,14 +37,18 @@ import "../cases/types/basewithoptions.js";
28
37
  import "../cases/types/is.js";
29
38
  import "../cases/types/proxyobserver.js";
30
39
  import "../cases/types/uniquequeue.js";
40
+ import "../cases/types/node.js";
31
41
  import "../cases/types/tokenlist.js";
32
42
  import "../cases/types/typeof.js";
43
+ import "../cases/types/uuid.js";
33
44
  import "../cases/types/mediatype.js";
34
45
  import "../cases/types/dataurl.js";
35
46
  import "../cases/types/base.js";
36
47
  import "../cases/types/version.js";
48
+ import "../cases/types/nodelist.js";
37
49
  import "../cases/types/id.js";
38
50
  import "../cases/types/randomid.js";
51
+ import "../cases/types/noderecursiveiterator.js";
39
52
  import "../cases/types/validate.js";
40
53
  import "../cases/types/stack.js";
41
54
  import "../cases/constraint/isobject.js";
@@ -55,6 +68,7 @@ import "../cases/data/extend.js";
55
68
  import "../cases/data/diff.js";
56
69
  import "../cases/data/buildmap.js";
57
70
  import "../cases/data/datasource.js";
71
+ import "../cases/data/buildtree.js";
58
72
  import "../cases/data/transformer.js";
59
73
  import "../cases/data/datasource/restapi.js";
60
74
  import "../cases/data/datasource/storage/sessionstorage.js";
@@ -10,13 +10,13 @@
10
10
  crossorigin="anonymous"
11
11
  referrerpolicy="no-referrer"></script>
12
12
 
13
- <script src="https://monsterjs.org/dist/1.24.0/dist/monster.dev.js"></script>
13
+ <script src="https://monsterjs.org/dist/1.27.0/dist/monster.dev.js"></script>
14
14
 
15
15
  </head>
16
16
  <body>
17
17
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
18
- <h1 style='margin-bottom: 0.1em;'>Monster 1.24.0</h1>
19
- <div id="lastupdate" style='font-size:0.7em'>last update So 14. Nov 07:59:39 CET 2021</div>
18
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.27.0</h1>
19
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Dez 16:42:51 CET 2021</div>
20
20
  </div>
21
21
  </body>
22
22
  </html>
@@ -14,8 +14,8 @@
14
14
  </head>
15
15
  <body>
16
16
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
17
- <h1 style='margin-bottom: 0.1em;'>Monster 1.24.0</h1>
18
- <div id="lastupdate" style='font-size:0.7em'>last update So 14. Nov 07:59:39 CET 2021</div>
17
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.27.0</h1>
18
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Dez 16:42:51 CET 2021</div>
19
19
  </div>
20
20
  </body>
21
21
  </html>
@@ -5,15 +5,15 @@
5
5
  <title>Mocha Monster</title>
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7
7
  <link rel="stylesheet" href="mocha.css"/>
8
- <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
8
+ <script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.filter,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,Document,DocumentFragment,Element,Event,fetch,globalThis,HTMLDocument,HTMLTemplateElement,Intl,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.freeze,Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,Uint16Array,Uint8Array,URL,WeakMap,WeakSet"
9
9
  crossorigin="anonymous"
10
10
  referrerpolicy="no-referrer"></script>
11
11
 
12
12
  </head>
13
13
  <body>
14
14
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
15
- <h1 style='margin-bottom: 0.1em;'>Monster 1.24.0</h1>
16
- <div id="lastupdate" style='font-size:0.7em'>last update So 14. Nov 07:59:39 CET 2021</div>
15
+ <h1 style='margin-bottom: 0.1em;'>Monster 1.27.0</h1>
16
+ <div id="lastupdate" style='font-size:0.7em'>last update Mo 6. Dez 16:42:51 CET 2021</div>
17
17
  </div>
18
18
  <div id="mocks"></div>
19
19
  <div id="mocha"></div>