mirror of
https://github.com/bigskysoftware/htmx.git
synced 2025-09-27 04:50:43 +00:00
Do not boost forms with method="dialog" (#2752)
* Do not boost forms with method="dialog" * Clean up
This commit is contained in:
parent
941e94fb98
commit
ee9b0e0390
@ -2277,7 +2277,7 @@ var htmx = (function() {
|
||||
* @param {HtmxTriggerSpecification[]} triggerSpecs
|
||||
*/
|
||||
function boostElement(elt, nodeData, triggerSpecs) {
|
||||
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || elt.tagName === 'FORM') {
|
||||
if ((elt instanceof HTMLAnchorElement && isLocalLink(elt) && (elt.target === '' || elt.target === '_self')) || (elt.tagName === 'FORM' && String(getRawAttribute(elt, 'method')).toLowerCase() !== 'dialog')) {
|
||||
nodeData.boosted = true
|
||||
let verb, path
|
||||
if (elt.tagName === 'A') {
|
||||
|
@ -71,6 +71,14 @@ describe('hx-boost attribute', function() {
|
||||
div.innerHTML.should.equal('Boosted')
|
||||
})
|
||||
|
||||
it('does not boost forms with method="dialog"', function() {
|
||||
make('<div hx-boost="true"><form id="f1" action="/test" method="dialog"><button id="b1">close</button></form></div>')
|
||||
var form = byId('f1')
|
||||
|
||||
var internalData = htmx._('getInternalData')(form)
|
||||
should.equal(undefined, internalData.boosted)
|
||||
})
|
||||
|
||||
it('handles basic anchor properly w/ data-* prefix', function() {
|
||||
this.server.respondWith('GET', '/test', 'Boosted')
|
||||
var div = make('<div data-hx-target="this" data-hx-boost="true"><a id="a1" href="/test">Foo</a></div>')
|
||||
|
Loading…
x
Reference in New Issue
Block a user