From c914b29e00c10a0fe75ee9e2ef1e1c1b5894ea36 Mon Sep 17 00:00:00 2001 From: treeFrog Date: Sat, 21 Dec 2024 09:39:26 -0800 Subject: [PATCH 1/3] Missing global variable some builder such as vitejs don't have global variable in this context --- src/resolveScrollableAncestorProp.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/resolveScrollableAncestorProp.js b/src/resolveScrollableAncestorProp.js index fa343ab..f589c29 100644 --- a/src/resolveScrollableAncestorProp.js +++ b/src/resolveScrollableAncestorProp.js @@ -2,8 +2,13 @@ export default function resolveScrollableAncestorProp(scrollableAncestor) { // When Waypoint is rendered on the server, `window` is not available. // To make Waypoint easier to work with, we allow this to be specified in // string form and safely convert to `window` here. + const globalWindow = + typeof window !== 'undefined' ? window : + typeof global !== 'undefined' && global.window ? global.window : + undefined; + if (scrollableAncestor === 'window') { - return global.window; + return globalWindow; } return scrollableAncestor; From dc6a45704d6f60ae889f2ef2d87911e5d82156fb Mon Sep 17 00:00:00 2001 From: treeFrog Date: Sat, 21 Dec 2024 09:41:27 -0800 Subject: [PATCH 2/3] Update resolveScrollableAncestorProp.js --- src/resolveScrollableAncestorProp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/resolveScrollableAncestorProp.js b/src/resolveScrollableAncestorProp.js index f589c29..180518d 100644 --- a/src/resolveScrollableAncestorProp.js +++ b/src/resolveScrollableAncestorProp.js @@ -2,12 +2,13 @@ export default function resolveScrollableAncestorProp(scrollableAncestor) { // When Waypoint is rendered on the server, `window` is not available. // To make Waypoint easier to work with, we allow this to be specified in // string form and safely convert to `window` here. - const globalWindow = + + if (scrollableAncestor === 'window') { + const globalWindow = typeof window !== 'undefined' ? window : typeof global !== 'undefined' && global.window ? global.window : undefined; - if (scrollableAncestor === 'window') { return globalWindow; } From fedde4ee63c19dfe23395e1d4cd195ca543cc3a3 Mon Sep 17 00:00:00 2001 From: treeFrog Date: Sat, 21 Dec 2024 09:42:08 -0800 Subject: [PATCH 3/3] Update resolveScrollableAncestorProp.js --- src/resolveScrollableAncestorProp.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/resolveScrollableAncestorProp.js b/src/resolveScrollableAncestorProp.js index 180518d..c863bc0 100644 --- a/src/resolveScrollableAncestorProp.js +++ b/src/resolveScrollableAncestorProp.js @@ -2,7 +2,6 @@ export default function resolveScrollableAncestorProp(scrollableAncestor) { // When Waypoint is rendered on the server, `window` is not available. // To make Waypoint easier to work with, we allow this to be specified in // string form and safely convert to `window` here. - if (scrollableAncestor === 'window') { const globalWindow = typeof window !== 'undefined' ? window :