Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/htmx.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ var htmx = (() => {
})

if (!this.__trigger(elt, "htmx:config:request", {ctx: ctx})) return
if (!this.#verbs.includes(ctx.request.method.toLowerCase())) return
if (ctx.request.method === 'DIALOG') return

let javascriptContent = this.__extractJavascriptContent(ctx.request.action);
if (javascriptContent != null) {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/fetch-mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class FetchMock {
// Mock a response for a specific URL pattern
mockResponse(method, urlPattern, response, options = {}) {
let upperCasedMethod = method.toUpperCase();
if (['GET', 'POST', 'PUT', 'PATCH', 'DELETE'].indexOf(upperCasedMethod) < 0) {
if (['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'QUERY'].indexOf(upperCasedMethod) < 0) {
throw Error("Invalid HTTP method: " + method)
}
if (typeof response === 'string') {
Expand Down
9 changes: 9 additions & 0 deletions test/tests/attributes/hx-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ describe('hx-action attribute', function() {
playground().innerHTML.should.equal('Put!')
})

it('hx-action with hx-method QUERY issues a QUERY request', async function() {
mockResponse('QUERY', '/test', 'Queried!')
let btn = createProcessedHTML('<button hx-action="/test" hx-method="QUERY">Click Me!</button>')
btn.click()
await forRequest()
fetchMock.calls[0].request.method.should.equal('QUERY')
btn.innerHTML.should.equal('Queried!')
})

})
8 changes: 0 additions & 8 deletions test/tests/unit/__handleTriggerEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ describe('__handleTriggerEvent unit tests', function() {
assert.isUndefined(window.testExecuted)
})

it('returns early if method not in verbs list', async function () {
let div = createProcessedHTML('<div hx-get="js:window.testExecuted = true"></div>')
let ctx = htmx.__createRequestContext(div, new Event('click'))
ctx.request.method = 'INVALID'
await htmx.__handleTriggerEvent(ctx)
assert.isUndefined(window.testExecuted)
})

it('executes javascript when action starts with js:', async function () {
let div = createProcessedHTML('<div hx-get="js:window.testExecuted = true"></div>')
let ctx = htmx.__createRequestContext(div, new Event('click'))
Expand Down
Loading