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
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | previewer-3408154-d10-each-fix.patch | 2.27 KB | interactivex |
| #2 | d10_previewer_once_fix.patch | 604 bytes | JoaoCoelho13 |
Comments
Comment #2
JoaoCoelho13 commentedComment #3
JoaoCoelho13 commentedI 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.
Comment #4
dineshkumarbollu commentedHi @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'.
to
once('previewerRefresh', '.js-previewerRefresh', context).forEach(() => {Your patch is also correct with jquery dependency.
Comment #5
interactivex commentedThanks for the great job @JoaoCoelho13. Your patch is only missing the missing dist JS. I've added it to a new patch.
Comment #7
thomasdik commentedHi 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