Skip to content

Commit

Permalink
fix: fix integration with vtex / spa
Browse files Browse the repository at this point in the history
  • Loading branch information
arturmagalhaesjr committed May 8, 2024
1 parent 50afa99 commit f7a7fd7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/sandbox/read-main-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);

Expand All @@ -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);
Expand Down

0 comments on commit f7a7fd7

Please sign in to comment.