Skip to content

Commit

Permalink
Do nextTick on recieving window global
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Brain committed Jun 30, 2016
1 parent 5057c6d commit 809e7cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/compat/global.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { CONSTANTS } from '../conf';
import { childWindows, promise } from '../lib';
import { childWindows, promise, nextTick } from '../lib';
import { receiveMessage } from '../drivers';

export function registerGlobals() {
Expand All @@ -17,7 +17,9 @@ export function registerGlobals() {
},

postMessage: promise.method(event => {
receiveMessage(event);
nextTick(() => {
receiveMessage(event);
});
}),

postMessageParent: promise.method((source, message, domain) => {
Expand Down
12 changes: 5 additions & 7 deletions src/drivers/send/strategies.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { CONSTANTS } from '../../conf';
import { util, promise, isSameDomain, nextTick } from '../../lib';
import { util, promise, isSameDomain } from '../../lib';
import { emulateIERestrictions, getBridge, getBridgeFor } from '../../compat';

export let SEND_MESSAGE_STRATEGIES = {
Expand Down Expand Up @@ -41,12 +41,10 @@ export let SEND_MESSAGE_STRATEGIES = {
throw new Error('postRobot not found on window');
}

nextTick(() => {
win[CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({
origin: `${window.location.protocol}//${window.location.host}`,
source: window,
data: JSON.stringify(message)
});
win[CONSTANTS.WINDOW_PROPS.POSTROBOT].postMessage({
origin: `${window.location.protocol}//${window.location.host}`,
source: window,
data: JSON.stringify(message)
});
}),

Expand Down

0 comments on commit 809e7cb

Please # to comment.