From 1cdaa6f13ae6c2e3d4f4ee0995f9f29d05829f21 Mon Sep 17 00:00:00 2001 From: Michael Fix Date: Wed, 17 Jul 2019 15:00:02 -0700 Subject: [PATCH] send embed postmessage to top window (#821) --- pages/embed.js | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pages/embed.js b/pages/embed.js index af67f98..faa96f5 100644 --- a/pages/embed.js +++ b/pages/embed.js @@ -2,7 +2,6 @@ import React from 'react' import Head from 'next/head' import { withRouter } from 'next/router' -import morph from 'morphmorph' // Ours import ApiContext from '../components/ApiContext' @@ -11,17 +10,6 @@ import Carbon from '../components/Carbon' import { DEFAULT_CODE, DEFAULT_SETTINGS } from '../lib/constants' import { getRouteState } from '../lib/routing' -const isInIFrame = morph.get('parent.window.parent') -const getParent = win => { - const iFrame = isInIFrame(win) - - if (iFrame) { - return iFrame - } - - return win.parent -} - const Page = props => ( @@ -80,7 +68,7 @@ class Embed extends React.Component { postMessage = () => { setTimeout( () => - getParent(window).postMessage( + window.top.postMessage( JSON.stringify({ // Used by embed provider src: window.location.toString(), @@ -96,7 +84,7 @@ class Embed extends React.Component { updateCode = code => { this.setState({ code }, this.postMessage) - getParent(window).postMessage( + window.top.postMessage( { id: this.state.id ? `carbon:${this.state.id}` : 'carbon', code