@schukai/monster 4.153.1 → 4.154.1
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/package.json +1 -1
- package/source/components/form/message-state-button.mjs +1 -1
- package/source/components/form/select-link.mjs +12 -1
- package/source/components/state/log.mjs +3 -7
- package/source/components/state/thread.mjs +3 -7
- package/source/components/time/day.mjs +0 -19
- package/source/components/time/month-calendar.mjs +5 -1
- package/source/data/buildmap.mjs +3 -3
- package/source/data/datasource.mjs +3 -10
- package/source/data/diff.mjs +13 -12
- package/source/data/extend.mjs +23 -1
- package/source/data/pathfinder.mjs +186 -19
- package/source/dom/customelement.mjs +273 -30
- package/source/dom/updater.mjs +6 -2
- package/source/types/base.mjs +7 -6
- package/source/types/basewithoptions.mjs +1 -8
- package/source/types/internal.mjs +4 -10
- package/source/types/observerlist.mjs +9 -17
- package/source/types/proxyobserver.mjs +19 -2
- package/source/types/tokenlist.mjs +13 -8
- package/source/util/clone.mjs +44 -14
- package/test/cases/browser-bundle.mjs +75 -0
- package/test/cases/components/datatable/drag-scroll.mjs +41 -9
- package/test/cases/components/navigation/site-navigation.mjs +10 -1
- package/test/cases/components/time/month-calendar.mjs +115 -0
- package/test/cases/data/diff.mjs +86 -0
- package/test/cases/data/extend.mjs +52 -0
- package/test/cases/data/pathfinder-resolution-baseline.mjs +322 -0
- package/test/cases/data/pathfinder.mjs +129 -0
- package/test/cases/dom/customelement-rebind-baseline.mjs +323 -0
- package/test/cases/dom/customelement-teardown.mjs +408 -0
- package/test/cases/dom/customelement.mjs +354 -0
- package/test/cases/dom/dimension.mjs +34 -10
- package/test/cases/dom/updater-remove.mjs +198 -0
- package/test/cases/packaging.mjs +213 -0
- package/test/cases/types/base.mjs +50 -0
- package/test/cases/types/observerlist.mjs +103 -1
- package/test/cases/types/proxyobserver.mjs +114 -0
- package/test/cases/types/regex.mjs +4 -0
- package/test/cases/types/tokenlist.mjs +64 -1
- package/test/cases/util/clone.mjs +115 -0
|
@@ -210,4 +210,119 @@ describe('Clone', function () {
|
|
|
210
210
|
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
+
describe('cyclic graphs and constructor free copies issue #573', function () {
|
|
214
|
+
|
|
215
|
+
class NeedsArgument {
|
|
216
|
+
constructor(required) {
|
|
217
|
+
if (required === undefined) {
|
|
218
|
+
throw new Error("required argument missing");
|
|
219
|
+
}
|
|
220
|
+
this.required = required;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
describe() {
|
|
224
|
+
return `value:${this.required}`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// net: behaviour that is already correct and must stay correct
|
|
229
|
+
it('should keep cloning plain nested structures deeply', function () {
|
|
230
|
+
let source = {a: {b: {c: 1}}, list: [1, {d: 2}]};
|
|
231
|
+
let result = clone(source);
|
|
232
|
+
|
|
233
|
+
expect(result).to.deep.equal(source);
|
|
234
|
+
expect(result.a).not.to.equal(source.a);
|
|
235
|
+
expect(result.list[1]).not.to.equal(source.list[1]);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('should keep the prototype and instanceof of a cloned class instance', function () {
|
|
239
|
+
let source = new A({x: 1});
|
|
240
|
+
let result = clone(source);
|
|
241
|
+
|
|
242
|
+
expect(result).to.be.instanceOf(A);
|
|
243
|
+
expect(Object.getPrototypeOf(result)).to.equal(Object.getPrototypeOf(source));
|
|
244
|
+
expect(typeof result.a).to.equal('function');
|
|
245
|
+
expect(result.b).to.deep.equal({x: 1});
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should keep honoring getClone()', function () {
|
|
249
|
+
let result = clone(new B({x: 1}));
|
|
250
|
+
expect(result).to.equal('DONE');
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// regression: a cyclic graph must terminate instead of exhausting the stack
|
|
254
|
+
it('should clone a self referencing object', function () {
|
|
255
|
+
let source = {name: 'root'};
|
|
256
|
+
source.self = source;
|
|
257
|
+
|
|
258
|
+
let result = clone(source);
|
|
259
|
+
|
|
260
|
+
expect(result).not.to.equal(source);
|
|
261
|
+
expect(result.name).to.equal('root');
|
|
262
|
+
expect(result.self).to.equal(result);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('should clone a cycle that runs through an array', function () {
|
|
266
|
+
let source = {items: []};
|
|
267
|
+
source.items.push(source);
|
|
268
|
+
|
|
269
|
+
let result = clone(source);
|
|
270
|
+
|
|
271
|
+
expect(result.items[0]).to.equal(result);
|
|
272
|
+
expect(result.items).not.to.equal(source.items);
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
it('should clone a mutual reference between two objects', function () {
|
|
276
|
+
let first = {name: 'first'};
|
|
277
|
+
let second = {name: 'second', first};
|
|
278
|
+
first.second = second;
|
|
279
|
+
|
|
280
|
+
let result = clone(first);
|
|
281
|
+
|
|
282
|
+
expect(result.second.first).to.equal(result);
|
|
283
|
+
expect(result.second).not.to.equal(second);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('should preserve a shared reference instead of duplicating it', function () {
|
|
287
|
+
let shared = {value: 1};
|
|
288
|
+
let source = {left: shared, right: shared};
|
|
289
|
+
|
|
290
|
+
let result = clone(source);
|
|
291
|
+
|
|
292
|
+
expect(result.left).to.equal(result.right);
|
|
293
|
+
expect(result.left).not.to.equal(shared);
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it('should keep honoring getClone() for an object reached inside a cycle', function () {
|
|
297
|
+
let source = {inner: new B({x: 1})};
|
|
298
|
+
source.self = source;
|
|
299
|
+
|
|
300
|
+
let result = clone(source);
|
|
301
|
+
|
|
302
|
+
expect(result.inner).to.equal('DONE');
|
|
303
|
+
expect(result.self).to.equal(result);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// regression: copying must not run the constructor of the source class
|
|
307
|
+
it('should clone an instance whose constructor requires an argument', function () {
|
|
308
|
+
let source = new NeedsArgument('payload');
|
|
309
|
+
|
|
310
|
+
let result = clone(source);
|
|
311
|
+
|
|
312
|
+
expect(result).to.be.instanceOf(NeedsArgument);
|
|
313
|
+
expect(result).not.to.equal(source);
|
|
314
|
+
expect(result.required).to.equal('payload');
|
|
315
|
+
expect(result.describe()).to.equal('value:payload');
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
it('should clone a nested instance whose constructor requires an argument', function () {
|
|
319
|
+
let source = {level: {instance: new NeedsArgument(7)}};
|
|
320
|
+
|
|
321
|
+
let result = clone(source);
|
|
322
|
+
|
|
323
|
+
expect(result.level.instance).to.be.instanceOf(NeedsArgument);
|
|
324
|
+
expect(result.level.instance.required).to.equal(7);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
213
328
|
});
|