on master help sign in
Debugger: fix module assignment to runtime with prototype magic.
commitcbe2c7a2da2e6d7c526669700b350ae18c215fd1 authorLaszlo Pandy <laszlo.pandy@prezi.com> dateWed 6 Nov 2013, 18:36 (13 years ago) parent52ae89c
1 file changed+11−4
runtime/Debugger.js+11−4
runtime/Debugger.js+11−4
@@ -113,12 +113,19 @@ function debugModule(module, runtime) {
113113
114114 // runtime is the prototype of wrappedRuntime
115115 // so we can access all runtime properties too
116− var wrappedRuntime = Object.create(runtime, {
117− notify: wrapNotify,
118− runDelayed: wrapRunDelayed
116+ var wrappedRuntime = Object.create(runtime);
117+ wrappedRuntime.notify = wrapNotify;
118+ wrappedRuntime.runDelayed = wrapRunDelayed;
119+
120+ var assignedPropTracker = Object.create(wrappedRuntime);
121+ var moduleInstance = module.make(assignedPropTracker);
122+ // The main module stores imported modules onto the runtime.
123+ // To ensure only one instance of each module is created,
124+ // we assign them back on the original runtime object.
125+ Object.keys(assignedPropTracker).forEach(function(key) {
126+ runtime[key] = assignedPropTracker[key];
119127 });
120128
121− var moduleInstance = module.make(wrappedRuntime);
122129 var moduleNodes = flattenNodes(wrappedRuntime.inputs);
123130 var tracePath = tracePathInit(runtime, moduleInstance.main);
124131