From 885596de0972e8f7968eb3855690f569636348b5 Mon Sep 17 00:00:00 2001 From: carson Date: Thu, 1 Oct 2020 09:29:48 -0600 Subject: [PATCH] include request configuration in events fixes https://github.com/bigskysoftware/htmx/issues/201 --- src/ext/path-deps.js | 6 +++--- src/htmx.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ext/path-deps.js b/src/ext/path-deps.js index 4a7b881f..e1264e79 100644 --- a/src/ext/path-deps.js +++ b/src/ext/path-deps.js @@ -18,13 +18,13 @@ htmx.defineExtension('path-deps', { onEvent: function (name, evt) { if (name === "htmx:afterRequest") { - var xhr = evt.detail.xhr; + var config = evt.detail.requestConfig; // mutating call - if (xhr.method !== "GET") { + if (config.verb !== "get") { var eltsWithDeps = htmx.findAll("[path-deps]"); for (var i = 0; i < eltsWithDeps.length; i++) { var elt = eltsWithDeps[i]; - if (dependsOn(elt.getAttribute('path-deps'), xhr.url)) { + if (dependsOn(elt.getAttribute('path-deps'), config.path)) { htmx.trigger(elt, "path-deps"); } } diff --git a/src/htmx.js b/src/htmx.js index a8307bf0..202eddd9 100644 --- a/src/htmx.js +++ b/src/htmx.js @@ -1721,7 +1721,7 @@ return (function () { } } - var eventDetail = {xhr: xhr, target: target}; + var eventDetail = {xhr: xhr, target: target, requestConfig:requestConfig}; xhr.onload = function () { try { if (!triggerEvent(elt, 'htmx:beforeOnLoad', eventDetail)) return;