Problem/Motivation
See #956186-189: Allow AJAX to use GET requests.
'method' has been in use for a long time. The original patch used 'type', but maybe we could change that to 'httpMethod'. If we make the change before 10.1.x, it won't be an API change.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | interdiff.txt | 594 bytes | lauriii |
| #14 | 3352984-14.patch | 2.95 KB | lauriii |
| #12 | interdiff.txt | 903 bytes | lauriii |
| #12 | 3352984-12.patch | 2.86 KB | lauriii |
| #3 | 3352984.patch | 2.55 KB | catch |
Comments
Comment #2
geek-merlin+1. Way more intuitive.
Comment #3
catchUntested patch. Couple of things I noticed:
- type was probably originally chosen because jQuery.ajax used 'type' for GET/POST.
- Since jQuery 1.9, it allows method, which type is a direct alias/bc for, although ajax.js relies on 'type' still, likely just because it's never been updated.
- as lauriii points out in the other issue, we can't use 'method' because we already use that for replacements.
So... trying httpMethod, I changed the one reference to jQuery AJAX 'type' to 'method' too here since that makes things slightly more consistent.
Passed through my mind that we should consider renaming 'method' to 'replaceMethod' in the AJAX API too, different issue if we wanted to do that though.
Comment #4
longwaveThrowing my hat into the bikeshed: these are commonly referred to as HTTP verbs, so if we can't use
methodwhat aboutverb?Comment #5
geek-merlin> so if we can't use method what about verb?
Good point. I would've had to scratch my head what this means though. So while technically more correct, maybe not so intuitive for some.
Also, i'd prefer httpMethod over method (and verb), because it includes the context, so its meaning is not dependent on additional context.
Comment #6
bkosborne+1 for httpMethod over verb. I appreciate the verbosity
Comment #7
wim leers“HTTP method” is more explicit than “method” or “verb” to my ears too.
Plus, it’s consistent with how Symfony refers to it in its route definitions.
Comment #8
smustgrave commentedIf I got a vote I like httpMethod.
Comment #9
longwaveAs a data attribute wouldn't this become
ajax-http-method? Data attributes usually use kebab-case instead of camelCase; automatic conversion is also done indatasetso this could also be referred to as$linkElement.dataset.ajaxHttpMethod.I also don't see any test coverage for this :(
Comment #10
smustgrave commentedJust to keep it moving, sending to NW for test coverage.
Comment #11
catchI don't think we should add test coverage for a direct rename, there is a lot of implicit coverage of the AJAX API via views but not much explicit. Leaving needs work for #9 though.
Comment #12
lauriiiAddressed the feedback and updated the comments.
Comment #13
longwaveI think this comment needs updating a bit given one part of it is no longer called "type". This comment didn't really add much anyway, not sure it is needed, although it is perhaps the only documentation for this feature.
I am still concerned there is no test coverage for data-ajax-type / data-ajax-http-method but I suppose that shouldn't hold this up otherwise we have to do a deprecation dance and so that can be deferred to a followup.
Comment #14
lauriiiThis should address #13.
Comment #15
smustgrave commentedOpened #3356611: Add test coverage for data-ajax-http-method attribute as a follow up.
Comment #17
longwaveCommitting this now so it can get in before the alpha release.
Committed and pushed cb77884135 to 10.1.x. Thanks!
Will update the change record to mention the new property name.
Comment #18
longwaveUpdated https://www.drupal.org/node/3193798 and linked it to this issue.