@schukai/monster 4.145.2 → 4.146.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.
@@ -292,6 +292,52 @@ describe('Select', function () {
292
292
  expect(mutateCount).to.equal(2);
293
293
  });
294
294
 
295
+ it('should suppress repeated safe floating layout oscillation', async function () {
296
+ const popper = document.createElement('div');
297
+ const rects = [
298
+ {x: 0, y: 0, width: 100, height: 40},
299
+ {x: 0, y: 0, width: 120, height: 40},
300
+ {x: 0, y: 0, width: 100, height: 40},
301
+ {x: 0, y: 0, width: 120, height: 40},
302
+ {x: 0, y: 0, width: 100, height: 40},
303
+ ];
304
+ let mutateCount = 0;
305
+
306
+ popper.getBoundingClientRect = () => {
307
+ const rect = rects[Math.min(mutateCount - 1, rects.length - 1)];
308
+ return {
309
+ ...rect,
310
+ top: rect.y,
311
+ left: rect.x,
312
+ right: rect.x + rect.width,
313
+ bottom: rect.y + rect.height,
314
+ };
315
+ };
316
+
317
+ const mutate = () => {
318
+ mutateCount += 1;
319
+ enqueueFloatingLayout({
320
+ popperElement: popper,
321
+ reason: FLOATING_LAYOUT_REASON.SETTLE,
322
+ mutate,
323
+ });
324
+ };
325
+
326
+ enqueueFloatingLayout({
327
+ popperElement: popper,
328
+ reason: FLOATING_LAYOUT_REASON.RESIZE,
329
+ mutate,
330
+ });
331
+
332
+ await flushFloatingLayoutQueueForTests();
333
+ await flushFloatingLayoutQueueForTests();
334
+ await flushFloatingLayoutQueueForTests();
335
+ await flushFloatingLayoutQueueForTests();
336
+ await flushFloatingLayoutQueueForTests();
337
+
338
+ expect(mutateCount).to.equal(4);
339
+ });
340
+
295
341
  it('should flush floating layout queue jobs when requestAnimationFrame stalls', async function () {
296
342
  const originalRequestAnimationFrame = global.requestAnimationFrame;
297
343
  const originalCancelAnimationFrame = global.cancelAnimationFrame;