From 809e7cbdc177f29e4af569f1739ef0b3f9a27c24 Mon Sep 17 00:00:00 2001 From: Daniel Brain Date: Thu, 30 Jun 2016 16:44:08 -0700 Subject: [PATCH] Do nextTick on recieving window global --- src/compat/global.js | 6 ++++-- src/drivers/send/strategies.js | 12 +++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/compat/global.js b/src/compat/global.js index ce0edff7..afa4cf98 100644 --- a/src/compat/global.js +++ b/src/compat/global.js @@ -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() { @@ -17,7 +17,9 @@ export function registerGlobals() { }, postMessage: promise.method(event => { - receiveMessage(event); + nextTick(() => { + receiveMessage(event); + }); }), postMessageParent: promise.method((source, message, domain) => { diff --git a/src/drivers/send/strategies.js b/src/drivers/send/strategies.js index 8be1319e..8e14206e 100644 --- a/src/drivers/send/strategies.js +++ b/src/drivers/send/strategies.js @@ -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 = { @@ -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) }); }),