Skip to content

Instantly share code, notes, and snippets.

@cpojer
Last active August 27, 2025 08:33
Show Gist options
  • Save cpojer/e66f9a082021a82230f2595a6027f161 to your computer and use it in GitHub Desktop.
Save cpojer/e66f9a082021a82230f2595a6027f161 to your computer and use it in GitHub Desktop.
diff --git a/lib/jsdom/browser/Window.js b/lib/jsdom/browser/Window.js
index 52d011cae61c3688ec64baa5cec411d55edbda9d..298d7ec8d2cc1ea5e974262b978e6041389900f7 100644
--- a/lib/jsdom/browser/Window.js
+++ b/lib/jsdom/browser/Window.js
@@ -507,8 +507,8 @@ function installOwnProperties(window, options) {
// [LegacyUnforgeable]:
window: { configurable: false },
document: { configurable: false },
- location: { configurable: false },
- top: { configurable: false }
+ location: { configurable: true },
+ top: { configurable: false },
});
@cpojer
Copy link
Author

cpojer commented Jun 9, 2025

Put this into a patches folder and add this configuration to your package.json:

"pnpm": {
    "patchedDependencies": {
      "jsdom": "patches/jsdom.patch"
    }
  }

@JoshMcCullough
Copy link

Using patch-package to apply this. 👍

@maapteh
Copy link

maapteh commented Aug 26, 2025

for jsdom 26.1.0 it shifted one line (i guess it will happen in between versions a lot)

diff --git a/lib/jsdom/browser/Window.js b/lib/jsdom/browser/Window.js
index 52d011cae61c3688ec64baa5cec411d55edbda9d..298d7ec8d2cc1ea5e974262b978e6041389900f7 100644
--- a/lib/jsdom/browser/Window.js
+++ b/lib/jsdom/browser/Window.js
@@ -507,8 +507,8 @@ function installOwnProperties(window, options) {
     // [LegacyUnforgeable]:
     window: { configurable: false },
     document: { configurable: false },
-    location: { configurable: false },
-    top: { configurable: false }
+    location: { configurable: true },
+    top: { configurable: false },
   });
 
 

@cpojer
Copy link
Author

cpojer commented Aug 27, 2025

@maapteh Thanks, I updated the gist.

@maapteh
Copy link

maapteh commented Aug 27, 2025

Maybe its handy to keep every version isolated, not many people need to stay latest. Thank you for your work! Hopefully something better will arrive with Jest :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment