Skip to content

Commit

Permalink
check that an xhr exists
Browse files Browse the repository at this point in the history
  • Loading branch information
1cg committed Dec 12, 2024
1 parent 5a8a738 commit dcdb191
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/head-support/head-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@
api = apiRef;

htmx.on('htmx:afterSwap', function(evt){
var serverResponse = evt.detail.xhr.response;
if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) {
mergeHead(serverResponse, evt.detail.boosted ? "merge" : "append");
let xhr = evt.detail.xhr;
if (xhr) {
var serverResponse = xhr.response;
if (api.triggerEvent(document.body, "htmx:beforeHeadMerge", evt.detail)) {
mergeHead(serverResponse, evt.detail.boosted ? "merge" : "append");
}
}
})

Expand All @@ -138,4 +141,4 @@
}
});

})()
})()

0 comments on commit dcdb191

Please sign in to comment.