on master help sign in
Debugger: move postMessage to new function.
c03c27fLaszlo Pandy
runtime/Debugger.js+15−11
@@ -8,22 +8,26 @@ Elm.debuggerAttach = function(module) {
8 make: function(runtime) {
8 make: function(runtime) {
9 var wrappedModule = debugModule(module, runtime);
9 var wrappedModule = debugModule(module, runtime);
10 Elm.Debugger = debuggerInit(wrappedModule, runtime);
10 Elm.Debugger = debuggerInit(wrappedModule, runtime);
11− if (parent.window) {
11+ dispatchElmDebuggerInit();
12− var dispatch = function(_) {
13− parent.window.postMessage("elmDebuggerInit", window.location.origin);
14− };
15− if (parent.window.document.readyState === "complete") {
16− dispatch();
17− }
18− else {
19− parent.window.addEventListener("load", dispatch);
20− }
21− }
22 return wrappedModule.moduleInstance;
12 return wrappedModule.moduleInstance;
23 }
13 }
24 };
14 };
25};
15};
26
16
17+function dispatchElmDebuggerInit() {
18+ if (parent.window) {
19+ var dispatch = function(_) {
20+ parent.window.postMessage("elmDebuggerInit", window.location.origin);
21+ };
22+ if (parent.window.document.readyState === "complete") {
23+ dispatch();
24+ }
25+ else {
26+ parent.window.addEventListener("load", dispatch);
27+ }
28+ }
29+}
30+
27function debugModule(module, runtime) {
31function debugModule(module, runtime) {
28 var programPaused = false;
32 var programPaused = false;
29 var recordedEvents = [];
33 var recordedEvents = [];