Problem/Motivation
Testing a site upgrade from D10.4.4 to 11.4.4 and noticed errors about isFunction() is not a function.
Proceeded to search codebase for occurrences of isFunction() in JS files and found entry in:
webform/js/webform.form.submit_once.js on line 47
Proposed resolution
Replace $.isFunction(jQuery.fn.valid) with (typeof jQuery.fn.valid === "function")
This is following the guidance from jQuery documentation:
https://api.jquery.com/jQuery.isFunction/
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 3512816_webform_test.png | 98.08 KB | danrod |
| #12 | 3512816_screen1.png | 55.94 KB | danrod |
| #3 | Replace_isFunction()_with_typeof_x_===_'function'.patch | 1.12 KB | kevin-oyster |
Issue fork webform-3512816
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
cilefen commentedThanks for the report. If the resolution is that very clear I am tagging this "Novice" for the next steps.
Comment #3
kevin-oyster commentedThanks cilefen,
Please see a patch we have used to test this. We haven't run extensive tests but similar changes resolves this issue in other code.
Comment #4
danrodComment #7
juandhr commentedI have created a merge request based on the patch provided by @kevin-oyster in Replace_isFunction()_with_typeof_x_===_'function'.patch. I have reviewed and tested the changes in a Drupal 11 environment, and everything is working as expected.
I am marking this as RTBC.
Comment #8
danrodSame, I don't see the
isFunctionanywhere too.Comment #9
mandclu commentedWouldn't it make more sense to use the vanilla JS
checkValidity()check and do away with the jQueryvalid()?Comment #11
mandclu commentedI made a new MR that uses the native Javascript method instead. Here is some documentation on the method I am suggesting.
Comment #12
danrodI tested the last MR (612) and I ran into this issue:
It seems like the
checkValidityfunction can't be used in the jQuery$formcontextwebform.form.submit_once.js?stdt80:47 Uncaught TypeError: $form.<code>checkValidityis not a functionat HTMLFormElement. (modules/contrib/webform/js/webform.form.submit_once.js?stdt80:47:65)
at HTMLFormElement.dispatch (jquery.min.js:2:38062)
at v.handle (jquery.min.js:2:36042)
The MR (610) worked with no issues
Comment #14
mandclu commentedRight,
$format that point is really a jQuery object. There would need to be a much more significant rewrite to remove the dependency here on jQuery.Moving this back to RTBC on the previous MR.
Comment #16
jrockowitz commentedComment #19
mandclu commented