Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Carson Gross 2023-11-19 07:56:40 -07:00
commit 52d19a47fb
6 changed files with 40 additions and 12 deletions

View File

@ -3533,6 +3533,18 @@ return (function () {
selectOverride = xhr.getResponseHeader("HX-Reselect");
}
// if we need to save history, do so, before swapping so that relative resources have the correct base URL
if (historyUpdate.type) {
triggerEvent(getDocument().body, 'htmx:beforeHistoryUpdate', mergeObjects({ history: historyUpdate }, responseInfo));
if (historyUpdate.type === "push") {
pushUrlIntoHistory(historyUpdate.path);
triggerEvent(getDocument().body, 'htmx:pushedIntoHistory', {path: historyUpdate.path});
} else {
replaceUrlInHistory(historyUpdate.path);
triggerEvent(getDocument().body, 'htmx:replacedInHistory', {path: historyUpdate.path});
}
}
var settleInfo = makeSettleInfo(target);
selectAndSwap(swapSpec.swapStyle, target, elt, serverResponse, settleInfo, selectOverride);
@ -3582,17 +3594,6 @@ return (function () {
triggerEvent(elt, 'htmx:afterSettle', responseInfo);
});
// if we need to save history, do so
if (historyUpdate.type) {
triggerEvent(getDocument().body, 'htmx:beforeHistoryUpdate', mergeObjects({ history: historyUpdate }, responseInfo));
if (historyUpdate.type === "push") {
pushUrlIntoHistory(historyUpdate.path);
triggerEvent(getDocument().body, 'htmx:pushedIntoHistory', {path: historyUpdate.path});
} else {
replaceUrlInHistory(historyUpdate.path);
triggerEvent(getDocument().body, 'htmx:replacedInHistory', {path: historyUpdate.path});
}
}
if (responseInfo.pathInfo.anchor) {
var anchorTarget = getDocument().getElementById(responseInfo.pathInfo.anchor);
if(anchorTarget) {

View File

@ -116,4 +116,3 @@ describe("hx-boost attribute", function() {
});
});

View File

@ -0,0 +1,10 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="application/javascript" src="../../../src/htmx.js"></script>
<title>hx-boost - Relative Resources Page 1</title>
</head>
<body style="padding:20px;font-family: sans-serif" hx-boost="true">
<a href="nested/page2.html">To Page 2</a>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,12 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="application/javascript" src="../../../../src/htmx.js"></script>
<title>hx-boost - Relative Resources Page 2</title>
</head>
<body style="padding:20px;font-family: sans-serif" hx-boost="true">
<a href="../index.html">Back To Page 1</a>
<p>Image should be displayed below</p>
<img src="img.png" />
</body>
</html>

View File

@ -37,6 +37,12 @@
<li><a href="history_style">History Style</a></li>
</ul>
</li>
<li>Boost Tests
<ul>
<li><a href="hxboost_relative_resources">Relative Resources</a></li>
<li><a href="hxboost_template_parsing">Template Parsing</a></li>
</ul>
</li>
</ul>
<h2>Perf</h2>
<li><a href="manual-perf.html">Manual Perf Test</a></li>