You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
remove singleton instance from communicator and only bind message events once in the primary and per spec bridge. Forward all message events to the respective communicator instance, if available.
* Initializes the event handler to receive messages from the spec bridge.
47
-
* @param {Window} win - a reference to the window object in the primary domain.
26
+
* The callback handler that receives messages from secondary domains.
27
+
* @param {MessageEvent.data} data - a reference to the MessageEvent.data sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
28
+
* @param {MessageEvent.source} source - a reference to the MessageEvent.source sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/source
@@ -183,20 +156,14 @@ export class SpecBridgeDomainCommunicator extends EventEmitter {
183
156
}
184
157
185
158
/**
186
-
* Initializes the event handler to receive messages from the primary domain.
187
-
* @param {Window} win - a reference to the window object in the spec bridge/iframe.
159
+
* The callback handler that receives messages from the primary domain.
160
+
* @param {MessageEvent.data} data - a reference to the MessageEvent.data sent through the postMessage event. See https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
188
161
* @returns {Void}
189
162
*/
190
-
initialize(win){
191
-
if(this.windowReference)return
192
-
193
-
this.windowReference=win
194
-
195
-
this.windowReference.addEventListener('message',({ data })=>{
196
-
if(!data)return
163
+
onMessage({ data }){
164
+
if(!data)return
197
165
198
-
this.emit(data.event,data.data)
199
-
},false)
166
+
this.emit(data.event,data.data)
200
167
}
201
168
202
169
/**
@@ -209,7 +176,7 @@ export class SpecBridgeDomainCommunicator extends EventEmitter {
0 commit comments