Skip to content

Commit

Permalink
Only go for fetching the one-level upper parent.
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunBarad committed Dec 20, 2024
1 parent cd9673d commit 0074f09
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions sim/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ namespace pxsim.unity {

//% blockId=helloUnity block="helloUnity"
export function helloUnity() {
let topLevelParent = undefined;
while (window.parent !== topLevelParent) {
topLevelParent = window.parent;
}
if (!topLevelParent) {
if (!window.parent) {
console.log('MakeCode: Parent not found');
} else {
console.log(`MakeCode: Parent found. It is: ${topLevelParent.document.title}`);
topLevelParent.postMessage({
console.log(`MakeCode: Parent found. It is: ${window.parent.document.title}`);
window.parent.postMessage({
codeCommand: 'SEND_MIXPANEL_EVENT',
codeData: {
eventName: "BtnClickBrowserVideoPlayerClose",
Expand Down

0 comments on commit 0074f09

Please sign in to comment.