@cesium/engine 21.0.0 → 21.0.1-ion.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.
Files changed (105) hide show
  1. package/Build/Workers/{chunk-EAYW4CFP.js → chunk-26ZRRKTU.js} +16 -16
  2. package/Build/Workers/{chunk-NP46ZIBY.js → chunk-2PX2ULSM.js} +3 -3
  3. package/Build/Workers/{chunk-3MSNTCHW.js → chunk-3K4DRV7Y.js} +9 -9
  4. package/Build/Workers/{chunk-7PLX65MV.js → chunk-3XTJC4CV.js} +5 -5
  5. package/Build/Workers/{chunk-S4NZVXU6.js → chunk-6KX3IUUT.js} +2 -2
  6. package/Build/Workers/{chunk-BDPSQXLX.js → chunk-75UG66GR.js} +5 -5
  7. package/Build/Workers/{chunk-EHFMZFVC.js → chunk-ADADBRLI.js} +4 -4
  8. package/Build/Workers/{chunk-YNLPRFUQ.js → chunk-AGT6W3JS.js} +6 -6
  9. package/Build/Workers/{chunk-OW6F6CPZ.js → chunk-AQ4A5CMC.js} +7 -7
  10. package/Build/Workers/{chunk-3PUG3T2H.js → chunk-B56XVJRS.js} +12 -12
  11. package/Build/Workers/{chunk-HJ7IZBEI.js → chunk-DTYIUWZU.js} +4 -4
  12. package/Build/Workers/{chunk-75B34CC6.js → chunk-E6T4LSM6.js} +5 -5
  13. package/Build/Workers/{chunk-2T4WAVWX.js → chunk-EEDSGIH7.js} +6 -6
  14. package/Build/Workers/{chunk-AR2FUSG6.js → chunk-EHMAKCWQ.js} +1 -1
  15. package/Build/Workers/{chunk-P6OAOFBU.js → chunk-ESPNIYL5.js} +8 -8
  16. package/Build/Workers/{chunk-CF72FAKC.js → chunk-EZJXK2UP.js} +4 -4
  17. package/Build/Workers/{chunk-LL6HN3W4.js → chunk-G5RX7BPJ.js} +10 -10
  18. package/Build/Workers/{chunk-UY2HVPDL.js → chunk-G74UMFQ4.js} +5 -5
  19. package/Build/Workers/{chunk-LNTUIO55.js → chunk-H3G7OYZY.js} +2 -2
  20. package/Build/Workers/{chunk-3G5XEUPY.js → chunk-HDBIC7IL.js} +1 -1
  21. package/Build/Workers/{chunk-K4IDXMIZ.js → chunk-JESBYOH5.js} +9 -9
  22. package/Build/Workers/{chunk-4VJYMLR6.js → chunk-KGL66RWW.js} +8 -8
  23. package/Build/Workers/{chunk-5GHCWGC4.js → chunk-L73TRTIG.js} +1 -1
  24. package/Build/Workers/{chunk-LWOCFJEH.js → chunk-LEFV6H2V.js} +9 -9
  25. package/Build/Workers/{chunk-64WSG7AT.js → chunk-LK7H6V2E.js} +4 -4
  26. package/Build/Workers/{chunk-UHVE7V65.js → chunk-LSNF6CIP.js} +12 -12
  27. package/Build/Workers/{chunk-E5XCZVIY.js → chunk-MBIUW42A.js} +1 -1
  28. package/Build/Workers/{chunk-3OPG2FGI.js → chunk-MFPT34BC.js} +4 -4
  29. package/Build/Workers/{chunk-ZYOHBCCE.js → chunk-MIFUV36K.js} +1 -1
  30. package/Build/Workers/{chunk-MXYW4BQ3.js → chunk-MJWRSKJV.js} +2 -2
  31. package/Build/Workers/{chunk-PXDMWXO5.js → chunk-NWJRIJQG.js} +2 -2
  32. package/Build/Workers/{chunk-TG7N7TPY.js → chunk-OLH67Z2S.js} +63 -32
  33. package/Build/Workers/{chunk-B7INTBBB.js → chunk-OWCFUM4Z.js} +13 -13
  34. package/Build/Workers/{chunk-JJZWDROM.js → chunk-PQW63B2T.js} +2 -2
  35. package/Build/Workers/{chunk-S2P6LCIB.js → chunk-RFZAUDYZ.js} +4 -4
  36. package/Build/Workers/{chunk-4PH27XAL.js → chunk-SDFGZML6.js} +2 -2
  37. package/Build/Workers/{chunk-5PEQUMCB.js → chunk-SF2XXYOB.js} +12 -12
  38. package/Build/Workers/{chunk-BU4CGMHO.js → chunk-SGEAS4NZ.js} +6 -6
  39. package/Build/Workers/{chunk-5B3PGBQW.js → chunk-T7WXNKIA.js} +11 -11
  40. package/Build/Workers/{chunk-FFCKCQPK.js → chunk-TXK2FF6N.js} +5 -5
  41. package/Build/Workers/{chunk-DJ4ROETJ.js → chunk-UTL4WVC3.js} +5 -5
  42. package/Build/Workers/{chunk-GKCZ2G36.js → chunk-UTTKH2UG.js} +7 -7
  43. package/Build/Workers/{chunk-N6DVKXZD.js → chunk-VIDWZGD6.js} +12 -12
  44. package/Build/Workers/{chunk-QS7623NH.js → chunk-WIPOMPA5.js} +6 -6
  45. package/Build/Workers/{chunk-6J6WGCWP.js → chunk-WJV24LAS.js} +4 -4
  46. package/Build/Workers/{chunk-JUOEBO4F.js → chunk-WMG6UOCJ.js} +10 -10
  47. package/Build/Workers/{chunk-TUZQG4RW.js → chunk-XFS2ORSO.js} +14 -14
  48. package/Build/Workers/{chunk-ARYRHDEB.js → chunk-XPTKQIVN.js} +6 -6
  49. package/Build/Workers/{chunk-ROH45IXJ.js → chunk-XYBFMHXA.js} +7 -7
  50. package/Build/Workers/{chunk-BUBVUXDO.js → chunk-YFZMB6FZ.js} +6 -6
  51. package/Build/Workers/{chunk-SGGO5WVA.js → chunk-ZOVMWDPW.js} +5 -5
  52. package/Build/Workers/{chunk-MMUISYW4.js → chunk-ZTGZMKAB.js} +16 -16
  53. package/Build/Workers/combineGeometry.js +21 -21
  54. package/Build/Workers/createBoxGeometry.js +15 -15
  55. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  56. package/Build/Workers/createCircleGeometry.js +23 -23
  57. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  60. package/Build/Workers/createCorridorGeometry.js +26 -26
  61. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  62. package/Build/Workers/createCylinderGeometry.js +17 -17
  63. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  64. package/Build/Workers/createEllipseGeometry.js +23 -23
  65. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  66. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  68. package/Build/Workers/createFrustumGeometry.js +15 -15
  69. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  70. package/Build/Workers/createGeometry.js +21 -21
  71. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  72. package/Build/Workers/createPlaneGeometry.js +13 -13
  73. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  74. package/Build/Workers/createPolygonGeometry.js +29 -29
  75. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  76. package/Build/Workers/createPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  79. package/Build/Workers/createRectangleGeometry.js +24 -24
  80. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  81. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  82. package/Build/Workers/createSphereGeometry.js +16 -16
  83. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  86. package/Build/Workers/createVectorTileGeometries.js +21 -21
  87. package/Build/Workers/createVectorTilePoints.js +11 -11
  88. package/Build/Workers/createVectorTilePolygons.js +19 -19
  89. package/Build/Workers/createVectorTilePolylines.js +12 -12
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  91. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  93. package/Build/Workers/createWallGeometry.js +21 -21
  94. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  95. package/Build/Workers/decodeDraco.js +10 -10
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +9 -9
  98. package/Build/Workers/gaussianSplatSorter.js +4 -4
  99. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  100. package/Build/Workers/transcodeKTX2.js +6 -6
  101. package/Build/Workers/transferTypedArrayTest.js +1 -1
  102. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  103. package/Source/Core/Event.js +76 -27
  104. package/index.js +209 -209
  105. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,18 +25,18 @@
25
25
 
26
26
  import {
27
27
  createTaskProcessorWorker_default
28
- } from "./chunk-LNTUIO55.js";
28
+ } from "./chunk-H3G7OYZY.js";
29
29
  import {
30
30
  RuntimeError_default
31
- } from "./chunk-PXDMWXO5.js";
31
+ } from "./chunk-NWJRIJQG.js";
32
32
  import {
33
33
  Check_default
34
- } from "./chunk-JJZWDROM.js";
34
+ } from "./chunk-PQW63B2T.js";
35
35
  import {
36
36
  __commonJS,
37
37
  __toESM,
38
38
  defined_default
39
- } from "./chunk-5GHCWGC4.js";
39
+ } from "./chunk-L73TRTIG.js";
40
40
 
41
41
  // node_modules/pako/lib/zlib/adler32.js
42
42
  var require_adler32 = __commonJS({
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,32 +25,32 @@
25
25
 
26
26
  import {
27
27
  require_draco_decoder_nodejs
28
- } from "./chunk-4PH27XAL.js";
28
+ } from "./chunk-SDFGZML6.js";
29
29
  import {
30
30
  Color_default
31
- } from "./chunk-SGGO5WVA.js";
31
+ } from "./chunk-ZOVMWDPW.js";
32
32
  import {
33
33
  createTaskProcessorWorker_default
34
- } from "./chunk-LNTUIO55.js";
34
+ } from "./chunk-H3G7OYZY.js";
35
35
  import {
36
36
  WebMercatorProjection_default
37
- } from "./chunk-BDPSQXLX.js";
37
+ } from "./chunk-75UG66GR.js";
38
38
  import {
39
39
  Cartesian3_default,
40
40
  Cartographic_default,
41
41
  Ellipsoid_default,
42
42
  Matrix3_default
43
- } from "./chunk-CF72FAKC.js";
43
+ } from "./chunk-EZJXK2UP.js";
44
44
  import {
45
45
  Math_default
46
- } from "./chunk-NP46ZIBY.js";
46
+ } from "./chunk-2PX2ULSM.js";
47
47
  import {
48
48
  Check_default
49
- } from "./chunk-JJZWDROM.js";
49
+ } from "./chunk-PQW63B2T.js";
50
50
  import {
51
51
  __toESM,
52
52
  defined_default
53
- } from "./chunk-5GHCWGC4.js";
53
+ } from "./chunk-L73TRTIG.js";
54
54
 
55
55
  // packages/engine/Source/Workers/decodeI3S.js
56
56
  var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -26,13 +26,13 @@
26
26
  import {
27
27
  initSync,
28
28
  radix_sort_gaussians_indexes
29
- } from "./chunk-ZYOHBCCE.js";
29
+ } from "./chunk-MIFUV36K.js";
30
30
  import {
31
31
  createTaskProcessorWorker_default
32
- } from "./chunk-LNTUIO55.js";
32
+ } from "./chunk-H3G7OYZY.js";
33
33
  import {
34
34
  defined_default
35
- } from "./chunk-5GHCWGC4.js";
35
+ } from "./chunk-L73TRTIG.js";
36
36
 
37
37
  // packages/engine/Source/Workers/gaussianSplatSorter.js
38
38
  async function initWorker(parameters, transferableObjects) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -26,13 +26,13 @@
26
26
  import {
27
27
  generate_splat_texture,
28
28
  initSync
29
- } from "./chunk-ZYOHBCCE.js";
29
+ } from "./chunk-MIFUV36K.js";
30
30
  import {
31
31
  createTaskProcessorWorker_default
32
- } from "./chunk-LNTUIO55.js";
32
+ } from "./chunk-H3G7OYZY.js";
33
33
  import {
34
34
  defined_default
35
- } from "./chunk-5GHCWGC4.js";
35
+ } from "./chunk-L73TRTIG.js";
36
36
 
37
37
  // packages/engine/Source/Workers/gaussianSplatTextureGenerator.js
38
38
  async function initWorker(parameters, transferableObjects) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -25,22 +25,22 @@
25
25
 
26
26
  import {
27
27
  createTaskProcessorWorker_default
28
- } from "./chunk-LNTUIO55.js";
28
+ } from "./chunk-H3G7OYZY.js";
29
29
  import {
30
30
  WebGLConstants_default
31
- } from "./chunk-3G5XEUPY.js";
31
+ } from "./chunk-HDBIC7IL.js";
32
32
  import {
33
33
  RuntimeError_default
34
- } from "./chunk-PXDMWXO5.js";
34
+ } from "./chunk-NWJRIJQG.js";
35
35
  import {
36
36
  Check_default
37
- } from "./chunk-JJZWDROM.js";
37
+ } from "./chunk-PQW63B2T.js";
38
38
  import {
39
39
  __commonJS,
40
40
  __require,
41
41
  __toESM,
42
42
  defined_default
43
- } from "./chunk-5GHCWGC4.js";
43
+ } from "./chunk-L73TRTIG.js";
44
44
 
45
45
  // packages/engine/Source/ThirdParty/Workers/basis_transcoder.js
46
46
  var require_basis_transcoder = __commonJS({
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @license
3
3
  * Cesium - https://github.com/CesiumGS/cesium
4
- * Version 1.134.0
4
+ * Version 1.134.1-ion.0
5
5
  *
6
6
  * Copyright 2011-2022 Cesium Contributors
7
7
  *
@@ -26,48 +26,48 @@
26
26
  import {
27
27
  EllipsoidalOccluder_default,
28
28
  TerrainEncoding_default
29
- } from "./chunk-K4IDXMIZ.js";
29
+ } from "./chunk-JESBYOH5.js";
30
30
  import {
31
31
  createTaskProcessorWorker_default
32
- } from "./chunk-LNTUIO55.js";
32
+ } from "./chunk-H3G7OYZY.js";
33
33
  import {
34
34
  OrientedBoundingBox_default
35
- } from "./chunk-3MSNTCHW.js";
35
+ } from "./chunk-3K4DRV7Y.js";
36
36
  import {
37
37
  AttributeCompression_default
38
- } from "./chunk-GKCZ2G36.js";
39
- import "./chunk-4VJYMLR6.js";
40
- import "./chunk-UY2HVPDL.js";
41
- import "./chunk-2T4WAVWX.js";
42
- import "./chunk-BUBVUXDO.js";
38
+ } from "./chunk-UTTKH2UG.js";
39
+ import "./chunk-KGL66RWW.js";
40
+ import "./chunk-G74UMFQ4.js";
41
+ import "./chunk-EEDSGIH7.js";
42
+ import "./chunk-YFZMB6FZ.js";
43
43
  import {
44
44
  IndexDatatype_default
45
- } from "./chunk-7PLX65MV.js";
45
+ } from "./chunk-3XTJC4CV.js";
46
46
  import {
47
47
  BoundingSphere_default
48
- } from "./chunk-BU4CGMHO.js";
48
+ } from "./chunk-SGEAS4NZ.js";
49
49
  import {
50
50
  Rectangle_default
51
- } from "./chunk-TG7N7TPY.js";
52
- import "./chunk-EHFMZFVC.js";
51
+ } from "./chunk-OLH67Z2S.js";
52
+ import "./chunk-ADADBRLI.js";
53
53
  import {
54
54
  Cartesian2_default,
55
55
  Cartesian3_default,
56
56
  Cartographic_default,
57
57
  Ellipsoid_default
58
- } from "./chunk-CF72FAKC.js";
58
+ } from "./chunk-EZJXK2UP.js";
59
59
  import {
60
60
  Math_default
61
- } from "./chunk-NP46ZIBY.js";
62
- import "./chunk-3G5XEUPY.js";
63
- import "./chunk-PXDMWXO5.js";
61
+ } from "./chunk-2PX2ULSM.js";
62
+ import "./chunk-HDBIC7IL.js";
63
+ import "./chunk-NWJRIJQG.js";
64
64
  import {
65
65
  Check_default,
66
66
  DeveloperError_default
67
- } from "./chunk-JJZWDROM.js";
67
+ } from "./chunk-PQW63B2T.js";
68
68
  import {
69
69
  defined_default
70
- } from "./chunk-5GHCWGC4.js";
70
+ } from "./chunk-L73TRTIG.js";
71
71
 
72
72
  // packages/engine/Source/Core/Intersections2D.js
73
73
  var Intersections2D = {};
@@ -27,8 +27,17 @@ function Event() {
27
27
  * @private
28
28
  */
29
29
  this._listeners = new Map();
30
- this._toRemove = [];
31
- this._insideRaiseEvent = false;
30
+ /**
31
+ * @type {Map<Listener,Set<object>>}
32
+ * @private
33
+ */
34
+ this._toRemove = new Map();
35
+ /**
36
+ * @type {Map<Listener,Set<object>>}
37
+ * @private
38
+ */
39
+ this._toAdd = new Map();
40
+ this._invokingListeners = false;
32
41
  this._listenerCount = 0; // Tracks number of listener + scope pairs
33
42
  }
34
43
 
@@ -63,22 +72,34 @@ Event.prototype.addEventListener = function (listener, scope) {
63
72
  //>>includeStart('debug', pragmas.debug);
64
73
  Check.typeOf.func("listener", listener);
65
74
  //>>includeEnd('debug');
75
+ const event = this;
66
76
 
67
- if (!this._listeners.has(listener)) {
68
- this._listeners.set(listener, new Set());
69
- }
70
- const scopes = this._listeners.get(listener);
71
- if (!scopes.has(scope)) {
72
- scopes.add(scope);
73
- this._listenerCount++;
77
+ const listenerMap = event._invokingListeners
78
+ ? event._toAdd
79
+ : event._listeners;
80
+ const added = addEventListener(this, listenerMap, listener, scope);
81
+ if (added) {
82
+ event._listenerCount++;
74
83
  }
75
84
 
76
- const event = this;
77
85
  return function () {
78
86
  event.removeEventListener(listener, scope);
79
87
  };
80
88
  };
81
89
 
90
+ function addEventListener(event, listenerMap, listener, scope) {
91
+ if (!listenerMap.has(listener)) {
92
+ listenerMap.set(listener, new Set());
93
+ }
94
+ const scopes = listenerMap.get(listener);
95
+ if (!scopes.has(scope)) {
96
+ scopes.add(scope);
97
+ return true;
98
+ }
99
+
100
+ return false;
101
+ }
102
+
82
103
  /**
83
104
  * Unregisters a previously registered callback.
84
105
  *
@@ -94,23 +115,47 @@ Event.prototype.removeEventListener = function (listener, scope) {
94
115
  Check.typeOf.func("listener", listener);
95
116
  //>>includeEnd('debug');
96
117
 
97
- const scopes = this._listeners.get(listener);
118
+ const removedFromListeners = removeEventListener(
119
+ this,
120
+ this._listeners,
121
+ listener,
122
+ scope,
123
+ );
124
+ const removedFromToAdd = removeEventListener(
125
+ this,
126
+ this._toAdd,
127
+ listener,
128
+ scope,
129
+ );
130
+
131
+ const removed = removedFromListeners || removedFromToAdd;
132
+ if (removed) {
133
+ this._listenerCount--;
134
+ }
135
+
136
+ return removed;
137
+ };
138
+
139
+ function removeEventListener(event, listenerMap, listener, scope) {
140
+ const scopes = listenerMap.get(listener);
98
141
  if (!scopes || !scopes.has(scope)) {
99
142
  return false;
100
143
  }
101
144
 
102
- if (this._insideRaiseEvent) {
103
- this._toRemove.push({ listener, scope });
145
+ if (event._invokingListeners) {
146
+ if (!addEventListener(event, event._toRemove, listener, scope)) {
147
+ // Already marked for removal
148
+ return false;
149
+ }
104
150
  } else {
105
151
  scopes.delete(scope);
106
152
  if (scopes.size === 0) {
107
- this._listeners.delete(listener);
153
+ listenerMap.delete(listener);
108
154
  }
109
155
  }
110
156
 
111
- this._listenerCount--;
112
157
  return true;
113
- };
158
+ }
114
159
 
115
160
  /**
116
161
  * Raises the event by calling each registered listener with all supplied arguments.
@@ -121,7 +166,7 @@ Event.prototype.removeEventListener = function (listener, scope) {
121
166
  * @see Event#removeEventListener
122
167
  */
123
168
  Event.prototype.raiseEvent = function () {
124
- this._insideRaiseEvent = true;
169
+ this._invokingListeners = true;
125
170
 
126
171
  for (const [listener, scopes] of this._listeners.entries()) {
127
172
  if (!defined(listener)) {
@@ -133,19 +178,23 @@ Event.prototype.raiseEvent = function () {
133
178
  }
134
179
  }
135
180
 
136
- // Actually remove items marked for removal
137
- if (this._toRemove.length > 0) {
138
- for (const { listener, scope } of this._toRemove) {
139
- const scopes = this._listeners.get(listener);
140
- scopes.delete(scope);
141
- if (scopes.size === 0) {
142
- this._listeners.delete(listener);
143
- }
181
+ this._invokingListeners = false;
182
+
183
+ // Actually add items marked for addition
184
+ for (const [listener, scopes] of this._toAdd.entries()) {
185
+ for (const scope of scopes) {
186
+ addEventListener(this, this._listeners, listener, scope);
144
187
  }
145
- this._toRemove.length = 0;
146
188
  }
189
+ this._toAdd.clear();
147
190
 
148
- this._insideRaiseEvent = false;
191
+ // Actually remove items marked for removal
192
+ for (const [listener, scopes] of this._toRemove.entries()) {
193
+ for (const scope of scopes) {
194
+ removeEventListener(this, this._listeners, listener, scope);
195
+ }
196
+ }
197
+ this._toRemove.clear();
149
198
  };
150
199
 
151
200
  /**