Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix Proxy custom props issue #1228

Merged
merged 2 commits into from
May 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/lib/src/common/window/windowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class WindowWrapper {
}

initProxyWindow() {
const customWindowPropsSet = new Set();
const handler = {
// here the proxy target is the global window object
get: function (target, property) {
Expand All @@ -34,7 +33,6 @@ class WindowWrapper {
// here we push to the custom props Set to know later if we want to bind the prop
// reflect just assigns the proprty and returns boolean if the assign was successfull
set: function (target, property, value) {
customWindowPropsSet.add(property);
return Reflect.set(target, property, value);
},
};
Expand All @@ -43,17 +41,21 @@ class WindowWrapper {
const windowFuncHandler = {
get: function (target, property) {
if (
!customWindowPropsSet.has(property) &&
!windowProxy.proGalleryCustomProps.has(property) &&
typeof windowProxy[property] === 'function'
) {
return windowProxy[property].bind(window);
}
return windowProxy[property];
},
set: function (target, property, value) {
windowProxy.proGalleryCustomProps.add(property);
return Reflect.set(windowProxy, property, value);
},
};
if (!windowProxy.proGalleryCustomProps) {
windowProxy.proGalleryCustomProps = new Set();
}
// this second proxy that returnes binded functions to avoid issues with non configurable proprties
// eslint-disable-next-line no-undef
this.window = new Proxy({}, windowFuncHandler);
Expand Down
Loading