@xuda.io/xuda-worker-bundle 1.3.2615 → 1.3.2616

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 (2) hide show
  1. package/index.js +16 -8
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -208,16 +208,24 @@ func.runtime.platform.off = function (name, handler) {
208
208
  handlers.splice(index, 1);
209
209
  }
210
210
  };
211
+ func.runtime.platform._emitting = {};
211
212
  func.runtime.platform.emit = function (name, data) {
212
- const handlers = func.runtime.platform._event_bus[name];
213
- if (handlers) {
214
- for (let i = 0; i < handlers.length; i++) {
215
- handlers[i](data);
213
+ // re-entrancy guard: prevent infinite loops when DOM bridge triggers the same event
214
+ if (func.runtime.platform._emitting[name]) return;
215
+ func.runtime.platform._emitting[name] = true;
216
+ try {
217
+ const handlers = func.runtime.platform._event_bus[name];
218
+ if (handlers) {
219
+ for (let i = 0; i < handlers.length; i++) {
220
+ handlers[i](data);
221
+ }
216
222
  }
217
- }
218
- // also fire on DOM if in browser (for backward compatibility with $(document).on listeners)
219
- if (func.runtime.platform.has_document() && typeof $ !== 'undefined') {
220
- $(document).trigger(name, Array.isArray(data) ? data : [data]);
223
+ // also fire on DOM if in browser (for backward compatibility with $(document).on listeners)
224
+ if (func.runtime.platform.has_document() && typeof $ !== 'undefined') {
225
+ $(document).trigger(name, Array.isArray(data) ? data : [data]);
226
+ }
227
+ } finally {
228
+ func.runtime.platform._emitting[name] = false;
221
229
  }
222
230
  };
223
231
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/xuda-worker-bundle",
3
- "version": "1.3.2615",
3
+ "version": "1.3.2616",
4
4
  "description": "xuda framework",
5
5
  "main": "index.js",
6
6
  "scripts": {