summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--src/htmx.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/htmx.js b/src/htmx.js
index 81802bfb..e49778fc 100644
--- a/src/htmx.js
+++ b/src/htmx.js
@@ -1516,6 +1516,7 @@ return (function () {
swapInnerHTML(historyElement, fragment, settleInfo)
settleImmediately(settleInfo.tasks);
currentPathForHistory = path;
+ triggerEvent(getDocument().body, "htmx:historyRestore", {path:path});
} else {
triggerErrorEvent(getDocument().body, "htmx:historyCacheMissLoadError", details);
}
@@ -1526,7 +1527,6 @@ return (function () {
function restoreHistory(path) {
saveHistory();
path = path || location.pathname+location.search;
- triggerEvent(getDocument().body, "htmx:historyRestore", {path:path});
var cached = getCachedHistory(path);
if (cached) {
var fragment = makeFragment(cached.content);
@@ -1537,6 +1537,7 @@ return (function () {
document.title = cached.title;
window.scrollTo(0, cached.scroll);
currentPathForHistory = path;
+ triggerEvent(getDocument().body, "htmx:historyRestore", {path:path});
} else {
if (htmx.config.refreshOnHistoryMiss) {
window.location.reload(true);
@@ -1789,6 +1790,10 @@ return (function () {
}
}
+ function isAnchorLink(elt) {
+ return getRawAttribute(elt, 'href') && getRawAttribute(elt, 'href').indexOf("#") >=0
+ }
+
function getSwapSpecification(elt) {
var swapInfo = getClosestAttributeValue(elt, "hx-swap");
var swapSpec = {
@@ -1796,6 +1801,9 @@ return (function () {
"swapDelay" : htmx.config.defaultSwapDelay,
"settleDelay" : htmx.config.defaultSettleDelay
}
+ if (getInternalData(elt).boosted && !isAnchorLink(elt)) {
+ swapSpec["show"] = "top"
+ }
if (swapInfo) {
var split = splitOnWhitespace(swapInfo);
if (split.length > 0) {