From f7a7fd7df8a09b6d7d2c2b785af32517598aa003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Artur=20Magalh=C3=A3es?= Date: Wed, 8 May 2024 10:35:10 -0400 Subject: [PATCH] fix: fix integration with vtex / spa --- src/lib/sandbox/read-main-platform.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts index bc4c85f1..3e6d3a36 100644 --- a/src/lib/sandbox/read-main-platform.ts +++ b/src/lib/sandbox/read-main-platform.ts @@ -93,11 +93,11 @@ const readImplementations = (impls: any[], interfaces: InterfaceInfo[]) => { const impl = implData[0]; const interfaceType: InterfaceType = implData[1] as any; const cstrName = getConstructorName(impl); - const CstrPrototype = (mainWindow as any)[cstrName].prototype; + const CstrPrototype = cstrName === 'History' ? History.prototype : (mainWindow as any)[cstrName].prototype; return [cstrName, CstrPrototype, impl, interfaceType]; - }); - - cstrImpls.map(([cstrName, CstrPrototype, impl, intefaceType]) => + }); + + cstrImpls.filter(([cstrName, CstrPrototype, impl, intefaceType])=> !!CstrPrototype).map(([cstrName, CstrPrototype, impl, intefaceType]) => readOwnImplementation(cstrs, interfaces, cstrName, CstrPrototype, impl, intefaceType) ); @@ -121,7 +121,7 @@ const readOwnImplementation = ( impl: any, interfaceType: InterfaceType ) => { - if (!cstrs.has(cstrName)) { + if (!cstrs.has(cstrName) && CstrPrototype) { cstrs.add(cstrName); const SuperCstr = Object.getPrototypeOf(CstrPrototype); const superCstrName = getConstructorName(SuperCstr);