mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-26 20:40:41 +00:00
fix outerHTML body swapping issue
fixes https://github.com/bigskysoftware/htmx/issues/2639
This commit is contained in:
parent
d35222446d
commit
f3ae976aa2
@ -1626,6 +1626,9 @@ var htmx = (function() {
|
||||
* @param {HtmxSettleInfo} settleInfo
|
||||
*/
|
||||
function swapOuterHTML(target, fragment, settleInfo) {
|
||||
if (target.tagName === "BODY") { // special case the body to innerHTML because DocumentFragments can't contain a body elt unfortunately
|
||||
return swapInnerHTML(target, fragment, settleInfo);
|
||||
}
|
||||
/** @type {Node} */
|
||||
let newElt
|
||||
const eltBeforeNewContent = target.previousSibling
|
||||
|
3
test/manual/body-swap/body.html
Normal file
3
test/manual/body-swap/body.html
Normal file
@ -0,0 +1,3 @@
|
||||
<body>
|
||||
<h1>A New Body, should still have a red border</h1>
|
||||
</body>
|
15
test/manual/body-swap/index.html
Normal file
15
test/manual/body-swap/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Body Swap Test</title>
|
||||
<script type="application/javascript" src="../../../src/htmx.js"></script>
|
||||
</head>
|
||||
<body style="padding: 20px; font-family: sans-serif;border: 6px solid red">
|
||||
<button hx-get="body.html"
|
||||
hx-target="body"
|
||||
hx-swap="outerHTML">
|
||||
Swap Body With outerHTML
|
||||
</button>
|
||||
</body>
|
||||
</html>
|
@ -17,6 +17,7 @@
|
||||
<li><a href="poll-condition-test.html">Poll Conditionals</a></li>
|
||||
<li><a href="poll-clears-on-reinit-test.html">Polling Cancels On Reprocessing</a></li>
|
||||
<li><a href="cache-buster">Cache Busting Test</a></li>
|
||||
<li><a href="body-swap">Body Swap Test</a></li>
|
||||
<li>Scroll Tests
|
||||
<ul>
|
||||
<li><a href="scroll-test-eventHandler.html">Scroll Event Handler</a></li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user