Skip to content

Commit ecf1a92

Browse files
adds browser new prop event listener
1 parent 713635e commit ecf1a92

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/components/modal/v2/lib/zoid-polyfill.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,23 @@ const IOS_INTERFACE_NAME = 'paypalMessageModalCallbackHandler';
77
const ANDROID_INTERFACE_NAME = 'paypalMessageModalCallbackHandler';
88

99
const setupBrowser = props => {
10+
const propListeners = new Set();
11+
12+
window.addEventListener(
13+
'message',
14+
newProps => {
15+
if (newProps && typeof newProps === 'object') {
16+
Array.from(propListeners.values()).forEach(listener => {
17+
listener({ ...window.xprops, ...newProps });
18+
});
19+
Object.assign(window.xprops, newProps);
20+
}
21+
},
22+
false
23+
);
24+
1025
window.xprops = {
11-
// We will never recieve new props via this integration style
12-
onProps: () => {},
26+
onProps: listener => propListeners.add(listener),
1327
// TODO: Verify these callbacks are instrumented correctly
1428
onReady: ({ products, meta }) => {
1529
const { clientId, payerId, merchantId, offer, partnerAttributionId } = props;

0 commit comments

Comments
 (0)