Problem/Motivation

After upgrading drupal Core version to 10 jQuery once is no longer supported.

For this module, this means that the js file needs to be updated. The file is 'previewerRefresh.behavior.js' and the error that appears in the console is that .each() is not a function.
The error points to line 12 of the file mentioned, it happens here ' once('previewerRefresh', '.js-previewerRefresh', context).each( ' .

Futhermore, the module js file that is passed to the website in the libraries.yml is created by running a 'build' script ( dist/js/previewerRefresh.behavior.js: { minified: true } ) .

My question is how can we updated the module making it compatible with drupal 10 ?

Should we create a patch for the module? How should we do it? I have tried creating a patch that changes 'previewerRefresh.behavior.js' but this isn´t the file that is provided to the website so it doesn´t change anything.

Steps to reproduce

Using previewer with drupal 10

Proposed resolution

Don't know yet.

Remaining tasks

Fixing the js problems.

User interface changes

API changes

Data model changes

Comments

JoaoCoelho13 created an issue. See original summary.

JoaoCoelho13’s picture

StatusFileSize
new604 bytes
JoaoCoelho13’s picture

I have uploaded the patch 'd10_previewer_once_fix.patch' as a trial. Since I am unable to test it in my environment, I am not sure that this patch works.

dineshkumarbollu’s picture

Hi @JoaoCoelho13

The issue in the repo code is they updated the js code without jquery dependency and using once dependency in it. If we use js once code without Jquery dependency then we need to update the 'each' to 'forEach'.

      once('previewerRefresh', '.js-previewerRefresh', context).each(() => {

to

once('previewerRefresh', '.js-previewerRefresh', context).forEach(() => {

Your patch is also correct with jquery dependency.

interactivex’s picture

StatusFileSize
new2.27 KB

Thanks for the great job @JoaoCoelho13. Your patch is only missing the missing dist JS. I've added it to a new patch.

thomasdik’s picture

Version: 1.0.0 » 1.0.8
Assigned: JoaoCoelho13 » Unassigned
Status: Active » Fixed

Hi All,

Thanks for the help!
This kind of slipped through when updating multiple modules.
I've added the latest version of the patch and released it.

Kind regards,

Thomas Dik

Status: Fixed » Closed (fixed)

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