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/

Issue fork webform-3512816

Command icon 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

kevin-oyster created an issue. See original summary.

cilefen’s picture

Version: 6.3.0-beta1 » 6.3.x-dev
Issue tags: +Novice

Thanks for the report. If the resolution is that very clear I am tagging this "Novice" for the next steps.

kevin-oyster’s picture

Thanks 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.

danrod’s picture

Status: Active » Needs review

juandhr made their first commit to this issue’s fork.

juandhr’s picture

Status: Needs review » Reviewed & tested by the community

I 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.

danrod’s picture

Same, I don't see the isFunction anywhere too.

mandclu’s picture

Wouldn't it make more sense to use the vanilla JS checkValidity() check and do away with the jQuery valid()?

mandclu’s picture

Status: Reviewed & tested by the community » Needs review

I made a new MR that uses the native Javascript method instead. Here is some documentation on the method I am suggesting.

danrod’s picture

StatusFileSize
new55.94 KB
new98.08 KB

I tested the last MR (612) and I ran into this issue:

Error submitting the webform

It seems like the checkValidity function can't be used in the jQuery $form context

webform.form.submit_once.js?stdt80:47 Uncaught TypeError: $form.<code>checkValidity is not a function
at 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

mandclu changed the visibility of the branch 3512816-checkvalidity to hidden.

mandclu’s picture

Status: Needs review » Reviewed & tested by the community

Right, $form at 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.

jrockowitz made their first commit to this issue’s fork.

jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

mandclu’s picture

Issue tags: +Atlanta2025

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.