From 4f69f966d39376ef7d4381fed5a1e19618212004 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Wed, 26 Jun 2024 23:59:54 -0500 Subject: [PATCH] fix: Setup `globalThis.location` & support class methods --- src/prerender.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/prerender.js b/src/prerender.js index bc3a759..be435bf 100644 --- a/src/prerender.js +++ b/src/prerender.js @@ -47,10 +47,13 @@ export default async function prerender(vnode, options) { * @param {string} path - current URL path */ export function locationStub(path) { + globalThis.location = {}; const u = new URL(path, 'http://localhost'); for (const i in u) { try { - globalThis.location[i] = String(u[i]); + globalThis.location[i] = /to[A-Z]/.test(i) + ? u[i].bind(u) + : String(u[i]); } catch {} } }