hx-push-url accepts a string

This commit is contained in:
Ben Croker 2020-06-26 15:35:33 +02:00 committed by GitHub
parent eb04ab5b3e
commit 3dc930dcb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1123,10 +1123,16 @@ return (function () {
}
function shouldPush(elt) {
return getClosestAttributeValue(elt, "hx-push-url") === "true" ||
var pushUrl = getClosestAttributeValue(elt, "hx-push-url");
return (pushUrl && pushUrl !== "false") ||
(elt.tagName === "A" && getInternalData(elt).boosted);
}
function getPushUrl(elt) {
var pushUrl = getClosestAttributeValue(elt, "hx-push-url");
return (pushUrl === "true" || pushUrl === "false") ? "" : pushUrl;
}
function addRequestIndicatorClasses(elt) {
mutateRequestIndicatorClasses(elt, "add");
}
@ -1541,7 +1547,7 @@ return (function () {
});
// push URL and save new page
if (shouldSaveHistory) {
var pathToPush = pushedUrl || finalPathForGet || path;
var pathToPush = pushedUrl || getPushUrl(elt) || finalPathForGet || path;
pushUrlIntoHistory(pathToPush);
triggerEvent(getDocument().body, 'pushedIntoHistory.htmx', {path:pathToPush});
}