repo: janusweb
action: commit
revision: 
path_from: 
revision_from: 5fbfe12fe230556b68cd5da0dc4bc94134a973b9:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit 5fbfe12fe230556b68cd5da0dc4bc94134a973b9
Author: James Baicoianu 
Date:   Wed May 8 12:35:06 2019 -0700

    Event bubbling for all dispatched events

diff --git a/scripts/janusbase.js b/scripts/janusbase.js
index 3e061e956164ddd963059ab50a0d762487ee3733..
index ..a4d7f229d2e1ee69c0a3d9ad9fec652642c20df9 100644
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -699,13 +699,19 @@ console.error('dunno what this is', other);
         this.anim_id = anim_id;
       }
     }
-    this.dispatchEvent = function(event) {
-      if (!event.element) event.element = this;
+    this.dispatchEvent = function(event, target) {
+      if (!event.element) event.element = target || this;
       var handlerfn = 'on' + event.type;
       if (this[handlerfn]) {
         this.executeCallback(this[handlerfn], event);
       }
-      return elation.events.fire(event);
+      // Bubble event up to parents, unless the event was thrown with bubbling disabled or an event handler called stopPropagation()
+      let firedev = elation.events.fire(event);
+      let returnValue = true;
+      firedev.forEach(e => returnValue &= e.returnValue);
+      if (event.bubbles !== false && returnValue && this.parent && this.parent.dispatchEvent) {
+        this.parent.dispatchEvent(event, event.target);
+      }
     }
     this.addEventListenerProxy = function(name, handler, bubble) {
       var eventobj = {

-----END OF PAGE-----