-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
attributes["hx-on::after-request"]
does not preserve double colon
#267
Comments
Would you be able to give a more detailed list of reproduction steps? This code that gets inserted into @Test
fun testDoubleColon() {
val html = buildString {
appendHTML(false).form {
attributes["hx-on::after-request"] = "if(event.detail.successful) this.reset()"
}
}
assertEquals("<form hx-on::after-request=\"if(event.detail.successful) this.reset()\"></form>", html)
} |
Here's a simplified version of my starting point: createHTMLDocument().html {
body {
form {
attributes["hx-on::after-request"] = "if (event.detail.successful) this.reset()"
}
}
}.serialize() This crashes with java.lang.RuntimeException: Namespace for prefix 'hx-on' has not been declared. I made the following change: createHTMLDocument().html {
+ attributes["xmlns:hx-on"] = "http://www.w3.org/1999/xhtml"
body {
form {
attributes["hx-on::after-request"] = "if (event.detail.successful) this.reset()"
}
}
}.serialize() This version doesn't crash, but the resulting HTML is missing a colon. Interestingly, replacing |
The immediate cause is that Java's XML parsing library views the colons as part of a namespace-based declaration, so it (unsuccessfully) attempts to look up the namespace |
I'm trying to use the approach suggested in bigskysoftware/htmx#1698 (comment) to reset a form after successful submission.
I'm having trouble with
attributes["hx-on::after-request"]
: only one colon appears in the rendered HTML.I'm using
.replace("hx-on:after-request", "hx-on::after-request")
as a workaround. Can you suggest a better solution?The text was updated successfully, but these errors were encountered: