@schukai/monster 1.25.0 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +15 -0
- package/README.md +3 -3
- 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 +1 -1
- package/dist/modules/dom/constants.js +1 -1
- 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 +1 -1
- 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 +620 -361
- 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 +25 -9
- package/source/data/buildtree.js +95 -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 +24 -24
- package/source/dom/customcontrol.js +1 -1
- package/source/dom/customelement.js +1 -1
- package/source/dom/events.js +4 -4
- 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 +5 -5
- package/source/dom/theme.js +3 -3
- package/source/dom/updater.js +5 -5
- 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 +179 -0
- package/source/types/nodelist.js +125 -0
- package/source/types/noderecursiveiterator.js +126 -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 +149 -0
- package/test/cases/dom/attributes.js +18 -14
- package/test/cases/dom/resource/link/stylesheet.js +1 -1
- 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 +196 -0
- package/test/cases/types/nodelist.js +64 -0
- package/test/cases/types/noderecursiveiterator.js +54 -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 +2 -2
- package/test/web/tests.js +3 -3
|
@@ -69,6 +69,7 @@ describe('Formatter', function () {
|
|
|
69
69
|
|
|
70
70
|
[
|
|
71
71
|
['${a | tojson}', "{\"b\":{\"c\":\"Hello\"},\"d\":\"World\",\"e\":1}"],
|
|
72
|
+
['click ${a.d} times', "click World times"],
|
|
72
73
|
[' ${a.b.c} ', ' Hello '],
|
|
73
74
|
[' ${a.b.c}', ' Hello'],
|
|
74
75
|
['${a.b.c} ', 'Hello '],
|
|
@@ -84,9 +85,8 @@ describe('Formatter', function () {
|
|
|
84
85
|
|
|
85
86
|
let a = data.shift()
|
|
86
87
|
let b = data.shift()
|
|
87
|
-
let c = data.shift()
|
|
88
88
|
|
|
89
|
-
it('format ' + a + ' should return ' +
|
|
89
|
+
it('format ' + a + ' should return ' + b, function () {
|
|
90
90
|
|
|
91
91
|
let obj = {
|
|
92
92
|
a: {
|
|
@@ -110,7 +110,7 @@ describe('Formatter', function () {
|
|
|
110
110
|
let text = '${mykey${subkey}}';
|
|
111
111
|
let expected = '1';
|
|
112
112
|
|
|
113
|
-
it('format ' + text + ' should '+expected, function () {
|
|
113
|
+
it('format ' + text + ' should ' + expected, function () {
|
|
114
114
|
|
|
115
115
|
let obj = {
|
|
116
116
|
mykey2: "1",
|
|
@@ -123,13 +123,44 @@ describe('Formatter', function () {
|
|
|
123
123
|
|
|
124
124
|
|
|
125
125
|
});
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
describe('setParameterChars()', function () {
|
|
128
|
+
|
|
129
|
+
it('setParameterChars() should return Instance', function () {
|
|
130
|
+
expect(new Formatter({}).setParameterChars('a', 'b')).is.instanceof(Formatter);
|
|
131
|
+
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
describe('with callbacks', function () {
|
|
139
|
+
|
|
140
|
+
it('add callback', function () {
|
|
141
|
+
const formatter = new Formatter({
|
|
142
|
+
x: '1'
|
|
143
|
+
}, {
|
|
144
|
+
callbacks: {
|
|
145
|
+
my: (value) => {
|
|
146
|
+
return "!" + value + "!"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
expect(formatter.format('${x | call:my}')).is.equal('!1!');
|
|
152
|
+
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
});
|
|
157
|
+
|
|
127
158
|
describe('Marker in marker with parameter', function () {
|
|
128
159
|
|
|
129
160
|
let text = '${mykey::mykey=${subkey}}';
|
|
130
161
|
let expected = '2';
|
|
131
162
|
|
|
132
|
-
it('format ' + text + ' should '+expected, function () {
|
|
163
|
+
it('format ' + text + ' should ' + expected, function () {
|
|
133
164
|
|
|
134
165
|
let obj = {
|
|
135
166
|
subkey: "2"
|
|
@@ -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
|
+
|
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.26.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.26.0</h1>
|
|
19
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 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.26.0</h1>
|
|
18
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 CET 2021</div>
|
|
19
19
|
</div>
|
|
20
20
|
</body>
|
|
21
21
|
</html>
|
package/test/web/test.html
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
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.26.0</h1>
|
|
16
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Do 2. Dez 10:00:50 CET 2021</div>
|
|
17
17
|
</div>
|
|
18
18
|
<div id="mocks"></div>
|
|
19
19
|
<div id="mocha"></div>
|