repo: janusweb action: commit revision: path_from: revision_from: f5e00168533ab9b0ab365c02949652c996cbc74e: path_to: revision_to:
commit f5e00168533ab9b0ab365c02949652c996cbc74e Author: James BaicoianuDate: Thu Aug 17 01:48:15 2017 -0700 Expose removeChild and dispatchEvent to scripts, execute named handlers automatically diff --git a/scripts/janusbase.js b/scripts/janusbase.js
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -169,7 +169,9 @@ elation.require(['engine.things.generic', 'utils.template'], function() {
createObject: ['function', 'createObject'],
appendChild: ['function', 'appendChild'],
+ removeChild: ['function', 'removeChild'],
addEventListener: ['function', 'addEventListenerProxy'],
+ dispatchEvent: ['function', 'dispatchEvent'],
removeEventListener: ['function', 'removeEventListenerProxy'],
localToWorld: ['function', 'localToWorld'],
worldToLocal: ['function', 'worldToLocal'],
@@ -411,6 +413,10 @@ console.error('dunno what this is', other);
}
this.dispatchEvent = function(event) {
if (!event.element) event.element = this;
+ var handlerfn = 'on' + event.type;
+ if (this[handlerfn]) {
+ this.executeCallback(this[handlerfn], event);
+ }
return elation.events.fire(event);
}
this.addEventListenerProxy = function(name, handler, bubble) {
-----END OF PAGE-----