@makefully/platypus 4.1.14 → 4.1.15
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.md +6 -0
- package/lib/platypus.js +1 -1
- package/package.json +1 -1
- package/src/components/EntityContainer.js +62 -17
package/package.json
CHANGED
|
@@ -187,6 +187,10 @@ const
|
|
|
187
187
|
},
|
|
188
188
|
|
|
189
189
|
addChildEventListeners (entity) {
|
|
190
|
+
if (this._destroyed) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
190
194
|
const
|
|
191
195
|
{_listeners} = entity;
|
|
192
196
|
|
|
@@ -219,33 +223,55 @@ const
|
|
|
219
223
|
},
|
|
220
224
|
|
|
221
225
|
removeChildEventListeners: function (entity) {
|
|
222
|
-
|
|
226
|
+
const
|
|
227
|
+
listener = entity.containerListener;
|
|
228
|
+
|
|
229
|
+
if (!listener) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const
|
|
234
|
+
{events} = listener,
|
|
235
|
+
// Prefer current shape; fall back to legacy `messages`.
|
|
236
|
+
handlers = listener.handlers ?? listener.messages;
|
|
237
|
+
|
|
238
|
+
if (events && handlers) {
|
|
223
239
|
const
|
|
224
|
-
{events, handlers} = entity.containerListener,
|
|
225
240
|
{length} = events;
|
|
226
241
|
|
|
227
242
|
for (let i = 0; i < length; i++) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
const
|
|
244
|
+
handler = handlers[i];
|
|
245
|
+
|
|
246
|
+
if (!handler) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (handler.callback) {
|
|
251
|
+
this.off(events[i], handler.callback, handler.context);
|
|
252
|
+
} else {
|
|
253
|
+
this.off(events[i], handler);
|
|
254
|
+
}
|
|
233
255
|
}
|
|
256
|
+
}
|
|
234
257
|
|
|
258
|
+
if (events) {
|
|
235
259
|
arrayCache.recycle(events);
|
|
236
|
-
arrayCache.recycle(handlers);
|
|
237
|
-
|
|
238
|
-
entity.containerListener.recycle();
|
|
239
|
-
entity.containerListener = null;
|
|
240
260
|
}
|
|
261
|
+
if (listener.handlers) {
|
|
262
|
+
arrayCache.recycle(listener.handlers);
|
|
263
|
+
}
|
|
264
|
+
if (listener.messages) {
|
|
265
|
+
arrayCache.recycle(listener.messages);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
listener.recycle();
|
|
269
|
+
entity.containerListener = null;
|
|
241
270
|
},
|
|
242
271
|
|
|
243
272
|
addChildEventListener: function (entity, event, handler) {
|
|
244
|
-
if (
|
|
245
|
-
|
|
246
|
-
"events", arrayCache.setUp(),
|
|
247
|
-
"handlers", arrayCache.setUp()
|
|
248
|
-
);
|
|
273
|
+
if (this._destroyed) {
|
|
274
|
+
return;
|
|
249
275
|
}
|
|
250
276
|
|
|
251
277
|
const
|
|
@@ -258,6 +284,13 @@ const
|
|
|
258
284
|
);
|
|
259
285
|
|
|
260
286
|
if (newHandler) {
|
|
287
|
+
if (!entity.containerListener) {
|
|
288
|
+
entity.containerListener = Data.setUp(
|
|
289
|
+
"events", arrayCache.setUp(),
|
|
290
|
+
"handlers", arrayCache.setUp()
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
261
294
|
entity.containerListener.events.push(event);
|
|
262
295
|
entity.containerListener.handlers.push(newHandler);
|
|
263
296
|
}
|
|
@@ -265,7 +298,19 @@ const
|
|
|
265
298
|
|
|
266
299
|
removeChildEventListener: function (entity, event, callback) {
|
|
267
300
|
const
|
|
268
|
-
|
|
301
|
+
listener = entity.containerListener;
|
|
302
|
+
|
|
303
|
+
if (!listener) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const
|
|
308
|
+
{events, handlers} = listener;
|
|
309
|
+
|
|
310
|
+
if (!events || !handlers) {
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
|
|
269
314
|
let i = events.length;
|
|
270
315
|
|
|
271
316
|
while (i--) {
|