mirror of
https://github.com/wassname/talk.git
synced 2026-08-14 12:50:17 +08:00
14 lines
298 B
JavaScript
14 lines
298 B
JavaScript
import { SCOPE, ORIGIN } from './constants';
|
|
|
|
export default (name, data, target = window.opener) => {
|
|
if (!target) {
|
|
return;
|
|
}
|
|
|
|
// Serialize the message to be sent via postMessage.
|
|
const msg = { name, data, scope: SCOPE };
|
|
|
|
// Send the message.
|
|
target.postMessage(msg, ORIGIN);
|
|
};
|