mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-26 20:40:41 +00:00
Better graceful degradation of boosted form element (#2802)
* better graceful degradation of form elt * smaller * move fix and add tests
This commit is contained in:
parent
c24adef38f
commit
8c6582679b
@ -2316,9 +2316,10 @@ var htmx = (function() {
|
||||
} else {
|
||||
const rawAttribute = getRawAttribute(elt, 'method')
|
||||
verb = (/** @type HttpVerb */(rawAttribute ? rawAttribute.toLowerCase() : 'get'))
|
||||
if (verb === 'get') {
|
||||
}
|
||||
path = getRawAttribute(elt, 'action')
|
||||
if (verb === 'get' && path.includes('?')) {
|
||||
path = path.replace(/\?[^#]+/, '')
|
||||
}
|
||||
}
|
||||
triggerSpecs.forEach(function(triggerSpec) {
|
||||
addEventListener(elt, function(node, evt) {
|
||||
|
@ -118,4 +118,29 @@ describe('hx-boost attribute', function() {
|
||||
this.server.respond()
|
||||
btn.innerHTML.should.equal('Boosted!')
|
||||
})
|
||||
|
||||
it('form get w/ search params in action property excludes search params', function() {
|
||||
this.server.respondWith('GET', /\/test.*/, function(xhr) {
|
||||
should.equal(undefined, getParameters(xhr).foo)
|
||||
xhr.respond(200, {}, 'Boosted!')
|
||||
})
|
||||
|
||||
var div = make('<div hx-target="this" hx-boost="true"><form id="f1" action="/test?foo=bar" method="get"><button id="b1">Submit</button></form></div>')
|
||||
var btn = byId('b1')
|
||||
btn.click()
|
||||
this.server.respond()
|
||||
div.innerHTML.should.equal('Boosted!')
|
||||
})
|
||||
|
||||
it('form post w/ query params in action property uses full url', function() {
|
||||
this.server.respondWith('POST', /\/test.*/, function(xhr) {
|
||||
should.equal(undefined, getParameters(xhr).foo)
|
||||
xhr.respond(200, {}, 'Boosted!')
|
||||
})
|
||||
var div = make('<div hx-target="this" hx-boost="true"><form id="f1" action="/test?foo=bar" method="post"><button id="b1">Submit</button></form></div>')
|
||||
var btn = byId('b1')
|
||||
btn.click()
|
||||
this.server.respond()
|
||||
div.innerHTML.should.equal('Boosted!')
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user