Skip to content

Commit

Permalink
Check for existence of stylesheet url before modifying it
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Cole committed Mar 25, 2024
1 parent 8665cce commit 5733738
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/reload-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,11 @@ class EleventyReload {
async onreload({ subtype, files, build }) {
if (subtype === "css") {
for (let link of document.querySelectorAll(`link[rel="stylesheet"]`)) {
let url = new URL(link.href);
url.searchParams.set("_11ty", Date.now());
link.href = url.toString();
if (link.href) {
let url = new URL(link.href);
url.searchParams.set("_11ty", Date.now());
link.href = url.toString();
}
}
Util.log(`CSS updated without page reload.`);
} else {
Expand Down

0 comments on commit 5733738

Please sign in to comment.