-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
When an element has hx-select="body"
applied to it, no content is selected from a given response, and instead a blank response is swapped in. For example, using the following:
import flask
app = flask.Flask(__name__)
@app.route("/")
def index():
return """<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js"></script>
</head>
<body>
<button hx-get="/alt" hx-target="body">click me</button>
</body>
</html>"""
@app.route("/alt")
def bad():
return """<!doctype html>
<body>
<div style="background-color: #df4093">swapped page</div>
<p>howdy</p>
</body>
</html>"""
Clicking the button when hx-select="body"
is applied will swap in an empty response.
If the hx-select
attribute is removed from the button, the contents of the response's body
will be swapped as normal (ironically, mimicking the behaviour expected when the attribute is present).
Unfortunately, I think there's more to this than just what is demonstrated here - this issue stems from a more complex error-handling setup in a larger app and I think there are other things going on there that might lead to the same condition happening that I've been struggling to isolate.
Cheers :)