Skip to content

Commit

Permalink
Merge pull request #1 from kadirahq/remove-serialization
Browse files Browse the repository at this point in the history
Remove serialization step because postMessage api does it
  • Loading branch information
Muhammed Thanish authored Sep 28, 2016
2 parents 9f6bb93 + af17685 commit f0e2545
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class PostmsgTransport {
this._buffer.push({ event, resolve, reject });
});
}
const data = JSON.stringify({ key: this._key, event });
const data = { key: this._key, event };
iframeWindow.postMessage(data, '*');
return Promise.resolve(null);
}
Expand Down Expand Up @@ -54,7 +54,10 @@ export class PostmsgTransport {
}

_handleEvent(e) {
const { key, event } = JSON.parse(e.data);
if(!e.data || typeof(e.data) !== 'object') {
return;
}
const { key, event } = e.data;
if (key !== this._key) {
return null;
}
Expand Down

0 comments on commit f0e2545

Please sign in to comment.