@schukai/monster 1.25.0 → 1.28.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +43 -0
- package/README.md +4 -4
- package/dist/modules/constants.js +1 -1
- package/dist/modules/constraints/abstract.js +1 -1
- package/dist/modules/constraints/abstractoperator.js +1 -1
- package/dist/modules/constraints/andoperator.js +1 -1
- package/dist/modules/constraints/invalid.js +1 -1
- package/dist/modules/constraints/isarray.js +1 -1
- package/dist/modules/constraints/isobject.js +1 -1
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +1 -1
- package/dist/modules/constraints/valid.js +1 -1
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/buildtree.js +2 -0
- package/dist/modules/data/datasource/namespace.js +1 -1
- package/dist/modules/data/datasource/restapi/writeerror.js +1 -1
- package/dist/modules/data/datasource/restapi.js +1 -1
- package/dist/modules/data/datasource/storage/localstorage.js +1 -1
- package/dist/modules/data/datasource/storage/namespace.js +1 -1
- package/dist/modules/data/datasource/storage/sessionstorage.js +1 -1
- package/dist/modules/data/datasource/storage.js +1 -1
- package/dist/modules/data/datasource.js +1 -1
- package/dist/modules/data/diff.js +1 -1
- package/dist/modules/data/extend.js +1 -1
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +1 -1
- package/dist/modules/data/pipe.js +1 -1
- package/dist/modules/data/transformer.js +1 -1
- package/dist/modules/dom/assembler.js +1 -1
- package/dist/modules/dom/attributes.js +2 -2
- package/dist/modules/dom/constants.js +2 -2
- package/dist/modules/dom/customcontrol.js +1 -1
- package/dist/modules/dom/customelement.js +1 -1
- package/dist/modules/dom/events.js +1 -1
- package/dist/modules/dom/focusmanager.js +1 -1
- package/dist/modules/dom/locale.js +1 -1
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/resource/data.js +1 -1
- package/dist/modules/dom/resource/link/stylesheet.js +1 -1
- package/dist/modules/dom/resource/link.js +1 -1
- package/dist/modules/dom/resource/script.js +1 -1
- package/dist/modules/dom/resource.js +1 -1
- package/dist/modules/dom/resourcemanager.js +1 -1
- package/dist/modules/dom/template.js +2 -2
- package/dist/modules/dom/theme.js +1 -1
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +1 -1
- package/dist/modules/dom/worker/factory.js +1 -1
- package/dist/modules/i18n/formatter.js +2 -0
- package/dist/modules/i18n/locale.js +1 -1
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +1 -1
- package/dist/modules/i18n/providers/fetch.js +1 -1
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +1 -1
- package/dist/modules/logging/handler/console.js +1 -1
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +1 -1
- package/dist/modules/logging/logentry.js +1 -1
- package/dist/modules/logging/logger.js +1 -1
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +1 -1
- package/dist/modules/monster.js +1 -1
- package/dist/modules/namespace.js +1 -1
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +1 -1
- package/dist/modules/types/basewithoptions.js +1 -1
- package/dist/modules/types/binary.js +1 -1
- package/dist/modules/types/dataurl.js +1 -1
- package/dist/modules/types/global.js +1 -1
- package/dist/modules/types/id.js +1 -1
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/mediatype.js +1 -1
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/node.js +2 -0
- package/dist/modules/types/nodelist.js +2 -0
- package/dist/modules/types/noderecursiveiterator.js +2 -0
- package/dist/modules/types/observer.js +1 -1
- package/dist/modules/types/observerlist.js +1 -1
- package/dist/modules/types/proxyobserver.js +1 -1
- package/dist/modules/types/queue.js +1 -1
- package/dist/modules/types/randomid.js +1 -1
- package/dist/modules/types/regex.js +2 -0
- package/dist/modules/types/stack.js +1 -1
- package/dist/modules/types/tokenlist.js +1 -1
- package/dist/modules/types/typeof.js +1 -1
- package/dist/modules/types/uniquequeue.js +1 -1
- package/dist/modules/types/uuid.js +1 -1
- package/dist/modules/types/validate.js +1 -1
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +1 -1
- package/dist/modules/util/comparator.js +1 -1
- package/dist/modules/util/freeze.js +1 -1
- package/dist/modules/util/namespace.js +1 -1
- package/dist/modules/util/processing.js +1 -1
- package/dist/modules/util/trimspaces.js +1 -1
- package/dist/monster.dev.js +1181 -708
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -2
- package/package.json +13 -2
- package/source/constraints/abstract.js +5 -0
- package/source/constraints/abstractoperator.js +5 -0
- package/source/constraints/andoperator.js +10 -5
- package/source/constraints/invalid.js +8 -3
- package/source/constraints/isarray.js +9 -4
- package/source/constraints/isobject.js +8 -3
- package/source/constraints/oroperator.js +10 -5
- package/source/constraints/valid.js +8 -3
- package/source/data/buildmap.js +27 -13
- package/source/data/buildtree.js +129 -0
- package/source/data/datasource/restapi.js +3 -3
- package/source/data/datasource/storage/localstorage.js +2 -2
- package/source/data/datasource/storage/sessionstorage.js +2 -2
- package/source/data/datasource/storage.js +3 -3
- package/source/data/datasource.js +3 -3
- package/source/data/diff.js +3 -3
- package/source/data/extend.js +2 -2
- package/source/data/pathfinder.js +4 -4
- package/source/data/pipe.js +3 -3
- package/source/data/transformer.js +3 -3
- package/source/dom/assembler.js +2 -2
- package/source/dom/attributes.js +111 -28
- package/source/dom/constants.js +17 -1
- package/source/dom/customcontrol.js +1 -1
- package/source/dom/customelement.js +1 -1
- package/source/dom/events.js +6 -7
- package/source/dom/focusmanager.js +6 -7
- package/source/dom/locale.js +8 -4
- package/source/dom/resource/data.js +2 -2
- package/source/dom/resource/link/stylesheet.js +2 -2
- package/source/dom/resource/link.js +2 -2
- package/source/dom/resource/script.js +2 -2
- package/source/dom/resource.js +2 -2
- package/source/dom/resourcemanager.js +2 -2
- package/source/dom/template.js +55 -15
- package/source/dom/theme.js +3 -3
- package/source/dom/updater.js +158 -98
- package/source/dom/util.js +6 -6
- package/source/dom/worker/factory.js +2 -2
- package/source/i18n/formatter.js +140 -0
- package/source/i18n/locale.js +6 -4
- package/source/i18n/provider.js +2 -2
- package/source/i18n/providers/fetch.js +18 -3
- package/source/i18n/translations.js +18 -9
- package/source/logging/handler/console.js +2 -2
- package/source/logging/handler.js +2 -2
- package/source/logging/logentry.js +2 -2
- package/source/logging/logger.js +2 -2
- package/source/math/random.js +2 -2
- package/source/namespace.js +1 -1
- package/source/text/formatter.js +190 -48
- package/source/types/base.js +2 -2
- package/source/types/basewithoptions.js +2 -2
- package/source/types/binary.js +4 -4
- package/source/types/dataurl.js +4 -4
- package/source/types/global.js +4 -4
- package/source/types/id.js +6 -3
- package/source/types/is.js +100 -82
- package/source/types/mediatype.js +4 -4
- package/source/types/node.js +210 -0
- package/source/types/nodelist.js +129 -0
- package/source/types/noderecursiveiterator.js +148 -0
- package/source/types/observer.js +3 -3
- package/source/types/observerlist.js +2 -2
- package/source/types/proxyobserver.js +5 -5
- package/source/types/queue.js +4 -4
- package/source/types/randomid.js +2 -2
- package/source/types/regex.js +49 -0
- package/source/types/stack.js +2 -2
- package/source/types/tokenlist.js +2 -2
- package/source/types/typeof.js +3 -3
- package/source/types/uniquequeue.js +2 -2
- package/source/types/uuid.js +2 -2
- package/source/types/validate.js +20 -20
- package/source/types/version.js +6 -6
- package/source/util/clone.js +2 -2
- package/source/util/comparator.js +3 -3
- package/source/util/freeze.js +2 -2
- package/source/util/processing.js +3 -3
- package/source/util/trimspaces.js +2 -2
- package/test/cases/data/buildtree.js +212 -0
- package/test/cases/dom/attributes.js +46 -19
- package/test/cases/dom/resource/link/stylesheet.js +1 -1
- package/test/cases/dom/template.js +72 -14
- package/test/cases/dom/updater.js +102 -75
- package/test/cases/i18n/formatter.js +66 -0
- package/test/cases/monster.js +1 -1
- package/test/cases/text/formatter.js +36 -5
- package/test/cases/types/node.js +252 -0
- package/test/cases/types/nodelist.js +71 -0
- package/test/cases/types/noderecursiveiterator.js +75 -0
- package/test/cases/types/regex.js +32 -0
- package/test/util/jsdom.js +0 -1
- package/test/web/import.js +6 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +3 -3
@@ -0,0 +1,252 @@
|
|
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
|
+
describe('Levels', function () {
|
196
|
+
|
197
|
+
it('n2 should level 2', function () {
|
198
|
+
|
199
|
+
const n0 = new Node('abc');
|
200
|
+
|
201
|
+
const n1 = new Node('def');
|
202
|
+
n0.appendChild(n1)
|
203
|
+
|
204
|
+
const n2 = new Node('ghi');
|
205
|
+
n1.appendChild(n2);
|
206
|
+
|
207
|
+
const n3 = new Node('jkl');
|
208
|
+
n2.appendChild(n3);
|
209
|
+
|
210
|
+
expect(n0.level).to.be.equal(0);
|
211
|
+
expect(n1.level).to.be.equal(1);
|
212
|
+
expect(n2.level).to.be.equal(2);
|
213
|
+
expect(n3.level).to.be.equal(3);
|
214
|
+
|
215
|
+
});
|
216
|
+
});
|
217
|
+
|
218
|
+
|
219
|
+
describe('toString()', function () {
|
220
|
+
|
221
|
+
it('should output empty string', function () {
|
222
|
+
const node = new Node();
|
223
|
+
expect(node.toString()).is.equal('');
|
224
|
+
});
|
225
|
+
|
226
|
+
it('should output string', function () {
|
227
|
+
const n0 = new Node('abc');
|
228
|
+
|
229
|
+
const n1 = new Node('def');
|
230
|
+
n0.appendChild(n1)
|
231
|
+
|
232
|
+
const n11 = new Node('ghi');
|
233
|
+
n0.appendChild(n11)
|
234
|
+
|
235
|
+
const n2 = new Node('jkl');
|
236
|
+
n1.appendChild(n2);
|
237
|
+
|
238
|
+
const n3 = new Node('mno');
|
239
|
+
n1.appendChild(n3);
|
240
|
+
|
241
|
+
const n4 = new Node('pqr');
|
242
|
+
n2.appendChild(n4);
|
243
|
+
|
244
|
+
expect(n2.level).to.be.equal(2)
|
245
|
+
|
246
|
+
console.log(n0.toString());
|
247
|
+
// expect(n0.toString()).is.equal('');
|
248
|
+
});
|
249
|
+
});
|
250
|
+
|
251
|
+
|
252
|
+
});
|
@@ -0,0 +1,71 @@
|
|
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
|
+
|
39
|
+
|
40
|
+
it('create NodeList', function () {
|
41
|
+
expect(new NodeList()).is.instanceof(NodeList);
|
42
|
+
})
|
43
|
+
|
44
|
+
it('add Node', function () {
|
45
|
+
expect(new NodeList().add(new Node())).to.be.instanceof(NodeList);
|
46
|
+
})
|
47
|
+
|
48
|
+
it('remove Node', function () {
|
49
|
+
expect(new NodeList().remove(new Node())).to.be.instanceof(NodeList);
|
50
|
+
})
|
51
|
+
|
52
|
+
it('has unknown Node', function () {
|
53
|
+
expect(new NodeList().has(new Node)).to.be.false;
|
54
|
+
})
|
55
|
+
|
56
|
+
it('has added Node', function () {
|
57
|
+
const n = new Node;
|
58
|
+
expect(new NodeList().add(n).has(n)).to.be.true;
|
59
|
+
})
|
60
|
+
|
61
|
+
it('toString', function () {
|
62
|
+
const n = new Node;
|
63
|
+
expect(new NodeList().add(new Node('a').appendChild(new Node('b'))).toString()).to.be.equal('a\n └b');
|
64
|
+
})
|
65
|
+
|
66
|
+
it('throw exception', function () {
|
67
|
+
expect(() => new NodeList().add(1)).to.throw(Error);
|
68
|
+
})
|
69
|
+
|
70
|
+
|
71
|
+
});
|
@@ -0,0 +1,75 @@
|
|
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('NodeRecursiveIterator', function () {
|
9
|
+
|
10
|
+
it('should throw exeption', function () {
|
11
|
+
expect(() => new NodeRecursiveIterator()).to.throw(Error)
|
12
|
+
});
|
13
|
+
it('should be a function', function () {
|
14
|
+
expect(NodeRecursiveIterator).to.be.a('function');
|
15
|
+
});
|
16
|
+
|
17
|
+
it('should be a constructor', function () {
|
18
|
+
expect(new NodeRecursiveIterator(new Node)).to.be.an.instanceof(NodeRecursiveIterator);
|
19
|
+
});
|
20
|
+
|
21
|
+
/**
|
22
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/yield
|
23
|
+
*/
|
24
|
+
it('undefined should not result in undefined node', function () {
|
25
|
+
const iterator = new NodeRecursiveIterator(new Node);
|
26
|
+
|
27
|
+
const result = [];
|
28
|
+
for (const n of iterator) {
|
29
|
+
expect(n).to.be.an.instanceof(Node);
|
30
|
+
result.push(n.value);
|
31
|
+
}
|
32
|
+
|
33
|
+
expect(result).to.deep.equal([undefined]);
|
34
|
+
|
35
|
+
});
|
36
|
+
|
37
|
+
it('should iterate', function () {
|
38
|
+
const node =
|
39
|
+
new Node('1')
|
40
|
+
node.appendChild(
|
41
|
+
(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')));
|
42
|
+
|
43
|
+
const iterator = new NodeRecursiveIterator(node);
|
44
|
+
|
45
|
+
const result = [];
|
46
|
+
for (const n of iterator) {
|
47
|
+
expect(n).to.be.an.instanceof(Node);
|
48
|
+
result.push(n.value);
|
49
|
+
}
|
50
|
+
|
51
|
+
expect(result).to.deep.equal(['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']);
|
52
|
+
|
53
|
+
});
|
54
|
+
|
55
|
+
it('should iterate nodelist', function () {
|
56
|
+
const nodeList = new NodeList();
|
57
|
+
|
58
|
+
nodeList.add(
|
59
|
+
(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'))));
|
60
|
+
|
61
|
+
nodeList.add(new Node('x'));
|
62
|
+
|
63
|
+
const iterator = new NodeRecursiveIterator(nodeList);
|
64
|
+
|
65
|
+
const result = [];
|
66
|
+
for (const n of iterator) {
|
67
|
+
expect(n).to.be.an.instanceof(Node);
|
68
|
+
result.push(n.value);
|
69
|
+
}
|
70
|
+
|
71
|
+
expect(result).to.deep.equal(['2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2', 'x']);
|
72
|
+
|
73
|
+
});
|
74
|
+
|
75
|
+
});
|
@@ -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
|
+
|
package/test/util/jsdom.js
CHANGED
@@ -15,7 +15,6 @@ export const isNode = new Function("try {return this===global;}catch(e){return f
|
|
15
15
|
*/
|
16
16
|
function initJSDOM(options) {
|
17
17
|
if (typeof window === "object" && window['DOMParser']) return Promise.resolve();
|
18
|
-
// if(isBrowser()) return Promise.resolve();
|
19
18
|
|
20
19
|
const g = getGlobal();
|
21
20
|
|
package/test/web/import.js
CHANGED
@@ -22,12 +22,14 @@ import "../cases/dom/worker/factory.js";
|
|
22
22
|
import "../cases/dom/focusmanager.js";
|
23
23
|
import "../cases/dom/events.js";
|
24
24
|
import "../cases/dom/customelement.js";
|
25
|
+
import "../cases/i18n/formatter.js";
|
25
26
|
import "../cases/i18n/providers/fetch.js";
|
26
27
|
import "../cases/i18n/translations.js";
|
27
28
|
import "../cases/i18n/locale.js";
|
28
29
|
import "../cases/i18n/provider.js";
|
29
30
|
import "../cases/types/queue.js";
|
30
31
|
import "../cases/types/binary.js";
|
32
|
+
import "../cases/types/regex.js";
|
31
33
|
import "../cases/types/observer.js";
|
32
34
|
import "../cases/types/global.js";
|
33
35
|
import "../cases/types/observerlist.js";
|
@@ -35,6 +37,7 @@ import "../cases/types/basewithoptions.js";
|
|
35
37
|
import "../cases/types/is.js";
|
36
38
|
import "../cases/types/proxyobserver.js";
|
37
39
|
import "../cases/types/uniquequeue.js";
|
40
|
+
import "../cases/types/node.js";
|
38
41
|
import "../cases/types/tokenlist.js";
|
39
42
|
import "../cases/types/typeof.js";
|
40
43
|
import "../cases/types/uuid.js";
|
@@ -42,8 +45,10 @@ import "../cases/types/mediatype.js";
|
|
42
45
|
import "../cases/types/dataurl.js";
|
43
46
|
import "../cases/types/base.js";
|
44
47
|
import "../cases/types/version.js";
|
48
|
+
import "../cases/types/nodelist.js";
|
45
49
|
import "../cases/types/id.js";
|
46
50
|
import "../cases/types/randomid.js";
|
51
|
+
import "../cases/types/noderecursiveiterator.js";
|
47
52
|
import "../cases/types/validate.js";
|
48
53
|
import "../cases/types/stack.js";
|
49
54
|
import "../cases/constraint/isobject.js";
|
@@ -63,6 +68,7 @@ import "../cases/data/extend.js";
|
|
63
68
|
import "../cases/data/diff.js";
|
64
69
|
import "../cases/data/buildmap.js";
|
65
70
|
import "../cases/data/datasource.js";
|
71
|
+
import "../cases/data/buildtree.js";
|
66
72
|
import "../cases/data/transformer.js";
|
67
73
|
import "../cases/data/datasource/restapi.js";
|
68
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.
|
13
|
+
<script src="https://monsterjs.org/dist/1.28.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.
|
19
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
18
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.28.0</h1>
|
19
|
+
<div id="lastupdate" style='font-size:0.7em'>last update So 12. Dez 10:22:38 CET 2021</div>
|
20
20
|
</div>
|
21
21
|
</body>
|
22
22
|
</html>
|
package/test/web/monster.html
CHANGED
@@ -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.
|
18
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
17
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.28.0</h1>
|
18
|
+
<div id="lastupdate" style='font-size:0.7em'>last update So 12. Dez 10:22:38 CET 2021</div>
|
19
19
|
</div>
|
20
20
|
</body>
|
21
21
|
</html>
|
package/test/web/test.html
CHANGED
@@ -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.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"
|
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.padStart,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.
|
16
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
15
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 1.28.0</h1>
|
16
|
+
<div id="lastupdate" style='font-size:0.7em'>last update So 12. Dez 10:22:38 CET 2021</div>
|
17
17
|
</div>
|
18
18
|
<div id="mocks"></div>
|
19
19
|
<div id="mocha"></div>
|