@schukai/monster 4.137.4 → 4.137.6

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.
@@ -43,6 +43,12 @@ const instanceSymbol = Symbol("instanceSymbol");
43
43
  const activeSubmenuHiderSymbol = Symbol("activeSubmenuHider");
44
44
  const hideHamburgerMenuSymbol = Symbol("hideHamburgerMenu");
45
45
  const hamburgerCloseButtonSymbol = Symbol("hamburgerCloseButton");
46
+ const layoutFrameSymbol = Symbol("layoutFrame");
47
+ const layoutSignatureSymbol = Symbol("layoutSignature");
48
+ const measurementCacheSymbol = Symbol("measurementCache");
49
+
50
+ const navigationItemIds = new WeakMap();
51
+ let navigationItemId = 0;
46
52
 
47
53
  function getAutoUpdateOptions() {
48
54
  return {
@@ -115,14 +121,16 @@ class SiteNavigation extends CustomElement {
115
121
  connectedCallback() {
116
122
  super.connectedCallback();
117
123
  attachResizeObserver.call(this);
118
- requestAnimationFrame(() => {
119
- populateTabs.call(this);
120
- });
124
+ schedulePopulateTabs.call(this);
121
125
  }
122
126
 
123
127
  disconnectedCallback() {
124
128
  super.disconnectedCallback();
125
129
  detachResizeObserver.call(this);
130
+ if (typeof this[layoutFrameSymbol] === "number") {
131
+ cancelAnimationFrame(this[layoutFrameSymbol]);
132
+ }
133
+ this[layoutFrameSymbol] = null;
126
134
  }
127
135
  }
128
136
 
@@ -300,14 +308,28 @@ function attachResizeObserver() {
300
308
  }
301
309
  }
302
310
  this[timerCallbackSymbol] = new DeadMansSwitch(200, () => {
303
- requestAnimationFrame(() => {
304
- populateTabs.call(this);
305
- });
311
+ schedulePopulateTabs.call(this);
306
312
  });
307
313
  });
308
314
  this[resizeObserverSymbol].observe(this);
309
315
  }
310
316
 
317
+ /**
318
+ * @private
319
+ * @this {SiteNavigation}
320
+ * @return {void}
321
+ */
322
+ function schedulePopulateTabs() {
323
+ if (typeof this[layoutFrameSymbol] === "number") {
324
+ return;
325
+ }
326
+
327
+ this[layoutFrameSymbol] = requestAnimationFrame(() => {
328
+ this[layoutFrameSymbol] = null;
329
+ populateTabs.call(this);
330
+ });
331
+ }
332
+
311
333
  /**
312
334
  * Disconnects and cleans up the ResizeObserver instance.
313
335
  * @private
@@ -595,6 +617,156 @@ function cloneNavItem(item) {
595
617
  return liClone;
596
618
  }
597
619
 
620
+ /**
621
+ * @private
622
+ * @param {HTMLElement} hamburgerButton
623
+ * @return {number}
624
+ */
625
+ function measureHamburgerWidth(hamburgerButton) {
626
+ const originalDisplay = hamburgerButton.style.display;
627
+ const originalVisibility = hamburgerButton.style.visibility;
628
+ setStyleValue(hamburgerButton, "visibility", "hidden");
629
+ setStyleValue(hamburgerButton, "display", "flex");
630
+ const width = Math.ceil(hamburgerButton.getBoundingClientRect().width) || 0;
631
+ setStyleValue(hamburgerButton, "display", originalDisplay);
632
+ setStyleValue(hamburgerButton, "visibility", originalVisibility);
633
+ return width;
634
+ }
635
+
636
+ /**
637
+ * @private
638
+ * @param {HTMLElement[]} sourceItems
639
+ * @param {string} sourceSignature
640
+ * @param {HTMLElement} visibleList
641
+ * @param {HTMLElement} navEl
642
+ * @return {object}
643
+ */
644
+ function getNavigationMeasurements(
645
+ sourceItems,
646
+ sourceSignature,
647
+ visibleList,
648
+ navEl,
649
+ ) {
650
+ const cache = this[measurementCacheSymbol];
651
+ if (cache?.sourceSignature === sourceSignature && cache.items.length > 0) {
652
+ return cache;
653
+ }
654
+
655
+ const originalOverflow = navEl.style.overflow;
656
+ const originalFlexWrap = visibleList.style.flexWrap;
657
+ const originalVisibility = visibleList.style.visibility;
658
+
659
+ setStyleValue(navEl, "overflow", "hidden");
660
+ setStyleValue(visibleList, "flexWrap", "nowrap");
661
+ setStyleValue(visibleList, "visibility", "hidden");
662
+
663
+ const clones = sourceItems.map(cloneNavItem);
664
+ visibleList.replaceChildren(...clones);
665
+
666
+ const items = clones.map((clone) => {
667
+ const submenu = clone.querySelector("ul, div[part='mega-menu']");
668
+ if (submenu instanceof HTMLElement) {
669
+ setStyleValue(submenu, "display", "none");
670
+ }
671
+ return {
672
+ requiredWidth: clone.offsetLeft + clone.offsetWidth,
673
+ width: clone.getBoundingClientRect().width || clone.offsetWidth || 0,
674
+ };
675
+ });
676
+ const gap = parseFloat(getComputedStyle(visibleList).gap || "0") || 0;
677
+
678
+ visibleList.replaceChildren();
679
+ setStyleValue(navEl, "overflow", originalOverflow);
680
+ setStyleValue(visibleList, "flexWrap", originalFlexWrap);
681
+ setStyleValue(visibleList, "visibility", originalVisibility);
682
+
683
+ this[measurementCacheSymbol] = {
684
+ gap,
685
+ items,
686
+ sourceSignature,
687
+ };
688
+ return this[measurementCacheSymbol];
689
+ }
690
+
691
+ /**
692
+ * @private
693
+ * @param {HTMLElement[]} sourceItems
694
+ * @return {string}
695
+ */
696
+ function getSourceItemsSignature(sourceItems) {
697
+ return sourceItems
698
+ .map((item) => {
699
+ return [
700
+ getNavigationItemId(item),
701
+ item.className || "",
702
+ item.textContent || "",
703
+ item.querySelectorAll("li").length,
704
+ ].join(":");
705
+ })
706
+ .join("|");
707
+ }
708
+
709
+ /**
710
+ * @private
711
+ * @param {HTMLElement} item
712
+ * @return {number}
713
+ */
714
+ function getNavigationItemId(item) {
715
+ let id = navigationItemIds.get(item);
716
+ if (id === undefined) {
717
+ id = ++navigationItemId;
718
+ navigationItemIds.set(item, id);
719
+ }
720
+ return id;
721
+ }
722
+
723
+ /**
724
+ * @private
725
+ * @param {object} params
726
+ * @return {string}
727
+ */
728
+ function getLayoutSignature({ fit, navWidth, rest }) {
729
+ return [
730
+ navWidth,
731
+ fit.map(getNavigationItemId).join(","),
732
+ rest.map(getNavigationItemId).join(","),
733
+ ].join("::");
734
+ }
735
+
736
+ /**
737
+ * @private
738
+ * @param {HTMLElement} element
739
+ * @param {string} property
740
+ * @param {string} value
741
+ * @return {void}
742
+ */
743
+ function setStyleValue(element, property, value) {
744
+ if (!(element instanceof HTMLElement)) {
745
+ return;
746
+ }
747
+ if (element.style[property] !== value) {
748
+ element.style[property] = value;
749
+ }
750
+ }
751
+
752
+ /**
753
+ * @private
754
+ * @param {HTMLElement} element
755
+ * @param {HTMLElement[]} children
756
+ * @return {void}
757
+ */
758
+ function replaceChildrenIfChanged(element, children) {
759
+ const currentSignature = Array.from(element.children)
760
+ .map((child) => [child.className || "", child.textContent || ""].join(":"))
761
+ .join("|");
762
+ const nextSignature = children
763
+ .map((child) => [child.className || "", child.textContent || ""].join(":"))
764
+ .join("|");
765
+ if (currentSignature !== nextSignature) {
766
+ element.replaceChildren(...children);
767
+ }
768
+ }
769
+
598
770
  /**
599
771
  * Measures available space and distributes slotted navigation items between
600
772
  * the visible list and the hidden hamburger menu list.
@@ -618,12 +790,12 @@ function populateTabs() {
618
790
  (ul) => ul.parentElement === this,
619
791
  );
620
792
 
621
- visibleList.innerHTML = "";
622
- hiddenList.innerHTML = "";
623
- hamburgerButton.style.display = "none";
624
793
  this.style.visibility = "hidden";
625
794
 
626
795
  if (!topLevelUl) {
796
+ replaceChildrenIfChanged.call(this, visibleList, []);
797
+ replaceChildrenIfChanged.call(this, hiddenList, []);
798
+ setStyleValue(hamburgerButton, "display", "none");
627
799
  this.style.visibility = "visible";
628
800
  return; // Nichts zu tun
629
801
  }
@@ -631,27 +803,29 @@ function populateTabs() {
631
803
  (n) => n.tagName === "LI",
632
804
  );
633
805
  if (sourceItems.length === 0) {
806
+ replaceChildrenIfChanged.call(this, visibleList, []);
807
+ replaceChildrenIfChanged.call(this, hiddenList, []);
808
+ setStyleValue(hamburgerButton, "display", "none");
634
809
  this.style.visibility = "visible";
635
810
  return;
636
811
  }
637
812
 
638
813
  const navWidth = navEl.clientWidth;
639
-
640
- const originalDisplay = hamburgerButton.style.display;
641
- hamburgerButton.style.visibility = "hidden";
642
- hamburgerButton.style.display = "flex";
643
- const hamburgerWidth =
644
- Math.ceil(hamburgerButton.getBoundingClientRect().width) || 0;
645
- hamburgerButton.style.display = originalDisplay;
646
- hamburgerButton.style.visibility = "visible";
647
-
648
- navEl.style.overflow = "hidden";
649
- visibleList.style.flexWrap = "nowrap";
650
- visibleList.style.visibility = "hidden"; // Inhalt der Liste während Manipulation ausblenden
814
+ const sourceSignature = getSourceItemsSignature(sourceItems);
815
+ const hamburgerWidth = measureHamburgerWidth(hamburgerButton);
816
+ const measurements = getNavigationMeasurements.call(
817
+ this,
818
+ sourceItems,
819
+ sourceSignature,
820
+ visibleList,
821
+ navEl,
822
+ );
651
823
 
652
824
  const fit = [];
653
825
  const rest = [];
654
826
  let hasOverflow = false;
827
+ const availableWidth = navWidth - hamburgerWidth;
828
+ const SAFETY_MARGIN = 1;
655
829
 
656
830
  for (let i = 0; i < sourceItems.length; i++) {
657
831
  const item = sourceItems[i];
@@ -661,12 +835,7 @@ function populateTabs() {
661
835
  continue;
662
836
  }
663
837
 
664
- const liClone = cloneNavItem(item);
665
- visibleList.appendChild(liClone);
666
-
667
- const requiredWidth = liClone.offsetLeft + liClone.offsetWidth;
668
- const availableWidth = navWidth - hamburgerWidth;
669
- const SAFETY_MARGIN = 1; // 1px Sicherheitsmarge für Subpixel-Rendering
838
+ const requiredWidth = measurements.items[i]?.requiredWidth || 0;
670
839
 
671
840
  if (requiredWidth > availableWidth + SAFETY_MARGIN) {
672
841
  hasOverflow = true;
@@ -677,49 +846,40 @@ function populateTabs() {
677
846
  }
678
847
 
679
848
  if (fit.length > 0 && rest.length > 0) {
680
- const lastVisibleItem = visibleList.children[fit.length - 1];
681
- const visibleItemsWidth =
682
- lastVisibleItem.offsetLeft + lastVisibleItem.offsetWidth;
683
-
684
- const firstHiddenItemClone = cloneNavItem(rest[0]);
685
- const submenu = firstHiddenItemClone.querySelector(
686
- "ul, div[part='mega-menu']",
687
- );
688
- if (submenu) submenu.style.display = "none";
689
-
690
- visibleList.appendChild(firstHiddenItemClone);
691
- const firstHiddenItemWidth =
692
- firstHiddenItemClone.getBoundingClientRect().width;
693
- visibleList.removeChild(firstHiddenItemClone);
694
-
695
- const gap = parseFloat(getComputedStyle(visibleList).gap || "0") || 0;
696
- if (visibleItemsWidth + gap + firstHiddenItemWidth <= navWidth) {
849
+ const visibleItemsWidth = measurements.items[fit.length - 1]?.requiredWidth || 0;
850
+ const firstHiddenIndex = sourceItems.indexOf(rest[0]);
851
+ const firstHiddenItemWidth = measurements.items[firstHiddenIndex]?.width || 0;
852
+ if (
853
+ visibleItemsWidth + measurements.gap + firstHiddenItemWidth <=
854
+ navWidth
855
+ ) {
697
856
  fit.push(rest.shift());
698
857
  }
699
858
  }
700
859
 
701
- navEl.style.overflow = "";
702
- visibleList.style.flexWrap = "";
703
- visibleList.innerHTML = "";
704
-
705
- if (fit.length) {
706
- const clonedVisible = fit.map(cloneNavItem);
707
- visibleList.append(...clonedVisible);
708
- visibleList
709
- .querySelectorAll(":scope > li")
710
- .forEach((li) => setupSubmenu.call(this, li, "visible", 1));
860
+ const layoutSignature = getLayoutSignature({ fit, navWidth, rest });
861
+ if (this[layoutSignatureSymbol] === layoutSignature) {
862
+ setStyleValue(visibleList, "visibility", "visible");
863
+ this.style.visibility = "visible";
864
+ return;
711
865
  }
866
+ this[layoutSignatureSymbol] = layoutSignature;
712
867
 
713
- if (rest.length) {
714
- const clonedHidden = rest.map(cloneNavItem);
715
- hiddenList.append(...clonedHidden);
716
- hamburgerButton.style.display = "flex";
717
- hiddenList
718
- .querySelectorAll(":scope > li")
719
- .forEach((li) => setupSubmenu.call(this, li, "hidden", 1));
720
- }
868
+ const clonedVisible = fit.map(cloneNavItem);
869
+ const clonedHidden = rest.map(cloneNavItem);
870
+ replaceChildrenIfChanged.call(this, visibleList, clonedVisible);
871
+ replaceChildrenIfChanged.call(this, hiddenList, clonedHidden);
872
+
873
+ visibleList
874
+ .querySelectorAll(":scope > li")
875
+ .forEach((li) => setupSubmenu.call(this, li, "visible", 1));
876
+
877
+ setStyleValue(hamburgerButton, "display", rest.length ? "flex" : "none");
878
+ hiddenList
879
+ .querySelectorAll(":scope > li")
880
+ .forEach((li) => setupSubmenu.call(this, li, "hidden", 1));
721
881
 
722
- visibleList.style.visibility = "visible";
882
+ setStyleValue(visibleList, "visibility", "visible");
723
883
  this.style.visibility = "visible";
724
884
  fireCustomEvent(this, "monster-layout-change", {
725
885
  visibleItems: fit,
@@ -156,7 +156,7 @@ function getMonsterVersion() {
156
156
  }
157
157
 
158
158
  /** don't touch, replaced by make with package.json version */
159
- monsterVersion = new Version("4.136.7");
159
+ monsterVersion = new Version("4.137.5");
160
160
 
161
161
  return monsterVersion;
162
162
  }
@@ -123,6 +123,16 @@ describe('Pagination', function () {
123
123
  expect(list).to.exist;
124
124
 
125
125
  list.setAttribute('data-monster-adaptive-ready', 'true');
126
+ control.refreshLayout();
127
+ list.setAttribute('data-monster-adaptive-ready', 'true');
128
+ let adaptiveReadyResetCount = 0;
129
+ const originalSetAttribute = list.setAttribute.bind(list);
130
+ list.setAttribute = (name, value) => {
131
+ if (name === 'data-monster-adaptive-ready' && value === 'false') {
132
+ adaptiveReadyResetCount++;
133
+ }
134
+ return originalSetAttribute(name, value);
135
+ };
126
136
  control.setPaginationState({currentPage: 2, totalPages: 5});
127
137
 
128
138
  expect(list.getAttribute('data-monster-adaptive-ready')).to.equal('true');
@@ -130,6 +140,7 @@ describe('Pagination', function () {
130
140
  setTimeout(() => {
131
141
  try {
132
142
  expect(list.getAttribute('data-monster-adaptive-ready')).to.equal('true');
143
+ expect(adaptiveReadyResetCount).to.equal(0);
133
144
  done();
134
145
  } catch (e) {
135
146
  done(e);
@@ -1,6 +1,7 @@
1
1
  import * as chai from "chai";
2
2
  import { chaiDom } from "../../../util/chai-dom.mjs";
3
3
  import { initJSDOM } from "../../../util/jsdom.mjs";
4
+ import { ResizeObserverMock } from "../../../util/resize-observer.mjs";
4
5
 
5
6
  let expect = chai.expect;
6
7
  chai.use(chaiDom);
@@ -94,4 +95,92 @@ describe("ButtonBar", function () {
94
95
  }
95
96
  }, 50);
96
97
  });
98
+
99
+ it("should coalesce resize layouts and avoid unchanged layout writes", async function () {
100
+ const OriginalResizeObserver = window.ResizeObserver;
101
+ const originalGlobalResizeObserver = globalThis.ResizeObserver;
102
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
103
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
104
+
105
+ class TrackingResizeObserver extends ResizeObserverMock {
106
+ static instances = [];
107
+
108
+ constructor(callback) {
109
+ super(callback);
110
+ TrackingResizeObserver.instances.push(this);
111
+ }
112
+ }
113
+
114
+ const scheduledCallbacks = [];
115
+ const flushFrames = async () => {
116
+ while (scheduledCallbacks.length > 0) {
117
+ scheduledCallbacks.shift()();
118
+ await new Promise((resolve) => setTimeout(resolve, 0));
119
+ }
120
+ };
121
+
122
+ try {
123
+ window.ResizeObserver = TrackingResizeObserver;
124
+ globalThis.ResizeObserver = TrackingResizeObserver;
125
+ window.requestAnimationFrame = (callback) => {
126
+ scheduledCallbacks.push(callback);
127
+ return scheduledCallbacks.length;
128
+ };
129
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
130
+
131
+ const mocks = document.getElementById("mocks");
132
+ mocks.innerHTML = `
133
+ <div id="button-bar-wrapper">
134
+ <monster-button-bar id="overflow-bar"></monster-button-bar>
135
+ </div>
136
+ `;
137
+
138
+ const wrapper = document.getElementById("button-bar-wrapper");
139
+ const bar = document.getElementById("overflow-bar");
140
+
141
+ wrapper.style.boxSizing = "border-box";
142
+ wrapper.style.width = "50px";
143
+ Object.defineProperty(wrapper, "clientWidth", {
144
+ configurable: true,
145
+ value: 50,
146
+ });
147
+
148
+ const switchButton = bar.shadowRoot.querySelector(
149
+ '[data-monster-role="switch"]',
150
+ );
151
+ Object.defineProperty(switchButton, "offsetWidth", {
152
+ configurable: true,
153
+ value: 20,
154
+ });
155
+
156
+ await flushFrames();
157
+
158
+ const resizeObserver = TrackingResizeObserver.instances.find((observer) =>
159
+ observer.elements.includes(wrapper),
160
+ );
161
+ expect(resizeObserver).to.exist;
162
+
163
+ let hiddenWriteCount = 0;
164
+ const originalSetAttribute = switchButton.setAttribute.bind(switchButton);
165
+ switchButton.setAttribute = (name, value) => {
166
+ if (name === "hidden") hiddenWriteCount++;
167
+ return originalSetAttribute(name, value);
168
+ };
169
+
170
+ resizeObserver.triggerResize([]);
171
+ resizeObserver.triggerResize([]);
172
+
173
+ expect(scheduledCallbacks.length).to.equal(1);
174
+ await flushFrames();
175
+
176
+ await new Promise((resolve) => setTimeout(resolve, 0));
177
+ expect(scheduledCallbacks.length).to.equal(0);
178
+ expect(hiddenWriteCount).to.equal(0);
179
+ } finally {
180
+ window.ResizeObserver = OriginalResizeObserver;
181
+ globalThis.ResizeObserver = originalGlobalResizeObserver;
182
+ window.requestAnimationFrame = originalRequestAnimationFrame;
183
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
184
+ }
185
+ });
97
186
  });
@@ -0,0 +1,126 @@
1
+ import * as chai from "chai";
2
+ import { initJSDOM } from "../../../util/jsdom.mjs";
3
+
4
+ const expect = chai.expect;
5
+
6
+ describe("Sheet", function () {
7
+ let Sheet;
8
+
9
+ before(function (done) {
10
+ initJSDOM()
11
+ .then(() => {
12
+ import("../../../../source/components/form/sheet.mjs")
13
+ .then((m) => {
14
+ Sheet = m.Sheet;
15
+ done();
16
+ })
17
+ .catch((e) => done(e));
18
+ })
19
+ .catch((e) => done(e));
20
+ });
21
+
22
+ afterEach(() => {
23
+ document.getElementById("mocks").innerHTML = "";
24
+ });
25
+
26
+ it("should register monster-sheet", function () {
27
+ expect(document.createElement("monster-sheet")).to.be.instanceof(Sheet);
28
+ });
29
+
30
+ it("should coalesce column resize pointer moves", function (done) {
31
+ const originalRequestAnimationFrame = window.requestAnimationFrame;
32
+ const originalGlobalRequestAnimationFrame = globalThis.requestAnimationFrame;
33
+ const originalCancelAnimationFrame = window.cancelAnimationFrame;
34
+ const originalGlobalCancelAnimationFrame = globalThis.cancelAnimationFrame;
35
+ const scheduledCallbacks = [];
36
+
37
+ try {
38
+ window.requestAnimationFrame = (callback) => {
39
+ scheduledCallbacks.push(callback);
40
+ return scheduledCallbacks.length;
41
+ };
42
+ globalThis.requestAnimationFrame = window.requestAnimationFrame;
43
+ window.cancelAnimationFrame = () => {};
44
+ globalThis.cancelAnimationFrame = window.cancelAnimationFrame;
45
+
46
+ const mocks = document.getElementById("mocks");
47
+ const sheet = document.createElement("monster-sheet");
48
+ mocks.appendChild(sheet);
49
+
50
+ setTimeout(() => {
51
+ try {
52
+ const grid = sheet.shadowRoot.querySelector(
53
+ '[data-monster-role="grid"]',
54
+ );
55
+ const handle = sheet.shadowRoot.querySelector(
56
+ '[data-monster-role="column-resize"]',
57
+ );
58
+ const header = handle.parentElement;
59
+ grid.setPointerCapture = () => {};
60
+ grid.releasePointerCapture = () => {};
61
+ Object.defineProperty(header, "getBoundingClientRect", {
62
+ configurable: true,
63
+ value: () => ({ width: 120 }),
64
+ });
65
+
66
+ let resizeEvents = 0;
67
+ sheet.addEventListener("monster-sheet-resize-column", () => {
68
+ resizeEvents++;
69
+ });
70
+
71
+ const down = new Event("pointerdown", { bubbles: true });
72
+ Object.assign(down, {
73
+ button: 0,
74
+ clientX: 100,
75
+ clientY: 0,
76
+ pointerId: 1,
77
+ });
78
+ handle.dispatchEvent(down);
79
+
80
+ const firstMove = new Event("pointermove", { bubbles: true });
81
+ Object.assign(firstMove, {
82
+ clientX: 130,
83
+ clientY: 0,
84
+ pointerId: 1,
85
+ });
86
+ const secondMove = new Event("pointermove", { bubbles: true });
87
+ Object.assign(secondMove, {
88
+ clientX: 150,
89
+ clientY: 0,
90
+ pointerId: 1,
91
+ });
92
+ grid.dispatchEvent(firstMove);
93
+ grid.dispatchEvent(secondMove);
94
+
95
+ expect(scheduledCallbacks.length).to.equal(1);
96
+ scheduledCallbacks.shift()();
97
+ expect(resizeEvents).to.equal(1);
98
+
99
+ const repeatedMove = new Event("pointermove", { bubbles: true });
100
+ Object.assign(repeatedMove, {
101
+ clientX: 150,
102
+ clientY: 0,
103
+ pointerId: 1,
104
+ });
105
+ grid.dispatchEvent(repeatedMove);
106
+ scheduledCallbacks.shift()();
107
+ expect(resizeEvents).to.equal(1);
108
+ done();
109
+ } catch (e) {
110
+ done(e);
111
+ } finally {
112
+ window.requestAnimationFrame = originalRequestAnimationFrame;
113
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
114
+ window.cancelAnimationFrame = originalCancelAnimationFrame;
115
+ globalThis.cancelAnimationFrame = originalGlobalCancelAnimationFrame;
116
+ }
117
+ }, 0);
118
+ } catch (e) {
119
+ window.requestAnimationFrame = originalRequestAnimationFrame;
120
+ globalThis.requestAnimationFrame = originalGlobalRequestAnimationFrame;
121
+ window.cancelAnimationFrame = originalCancelAnimationFrame;
122
+ globalThis.cancelAnimationFrame = originalGlobalCancelAnimationFrame;
123
+ done(e);
124
+ }
125
+ });
126
+ });