jQuery Once console errors

Created on 21 November 2023, 10 months ago
Updated 17 April 2024, 5 months ago

Problem/Motivation

When using the Highcharts module and rendering the charts on my page, I see the attached errors in the console. This appears to be due to the deprecation of the `jquery.once` library and requires a replacement to `once`.

Steps to reproduce

1. Render a graph on a Drupal 10 site using Highcharts
2. Check the console for any JS errors

I am currently only using the highcharts submodule for this but there may be other integrations which require this update.

Proposed resolution

Update the existing libraries and Javascript to switch the dependencies from jquery.once to just once and swap the implementation in the JavaScript to use the once() function as per this documentation: https://www.drupal.org/node/3158256

🐛 Bug report
Status

Needs review

Version

3.5

Component

Highcharts integration

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jaymehls
  • 🇺🇸United States andileco

    @jaymehls, I have been trying to depreciate the 8.x-3.x version of Charts in favor of 5.0.x for years. Is there any reason (like a custom module) that you have not upgraded to the 5.0.x version? If not, that's definitely the next step to take, and you'll inherit lots of other improvements too.

  • @andileco it makes sense regarding the deprecation. We are currently halfway through a Drupal 10 upgrade and we have a large amount of custom legacy code from about 5 years ago that is driving the creation of charts from a Webform (a class with over 1000 lines). As you can imagine the upgrade process for this is rather tough and will require some input to move to the new version, though if the recommended approach here is to upgrade, it might be the time to go ahead and do it.

    If there are plans to pull support on the 3.x version at some point, we should probably do the upgrade as soon as we can.

    Thanks

  • First commit to issue fork.
  • 🇮🇳India sarwan_verma

    Hi ,
    I have fixed this issue "Highcharts - jQuery Once console errors" and also attached patch ,
    please review and verify.

  • Merge request !70Fixed jQuery Once errors → (Open) created by Unnamed author
  • Status changed to Needs review 10 months ago
  • Status changed to Needs work 10 months ago
  • 🇺🇸United States andileco

    @sarwan_verma, your patch addresses part of the issue, but the JS file needs to be updated too. Currently, it looks like:

    $('.charts-highchart').once().each(function () {
    

    and it will need to look more like:

    once('add_chart_attributes', '.charts-highchart', context).forEach(
    

    See: https://www.drupal.org/docs/drupal-apis/javascript-api/javascript-api-ov...

  • First commit to issue fork.
  • 🇺🇸United States NicholasS

    I am blocked from 5.x due to another module

    Problem 1
    - Root composer.json requires drupal/charts ^5.0, found drupal/charts[dev-5.0.x, 5.0.0-alpha1, ..., 5.0.x-dev] but these were not loaded, likely because it conflicts with another require.
    Problem 2
    - drupal/charts_field_formatter is locked to version dev-3369229-automated-drupal-10-charts-3.3 and an update of this package was not requested.
    - drupal/charts_field_formatter dev-3369229-automated-drupal-10-charts-3.3 requires drupal/charts ^3.3 -> found drupal/charts[dev-3.x, 3.3.0, 3.4.0, 3.5.0, 3.x-dev (alias of dev-3.x)] but it conflicts with your root composer.json require (^5.0).

  • 🇺🇸United States andileco

    Hey NicholasS, a plug for migrating to 5.x, as that capability is in-built in Charts 5.x (see the attached video). Obviously, it can be complicated to do, especially when that module blocks upgrading, but I think it will be very well-worth it if you can finagle it.

  • First commit to issue fork.
  • Status changed to Needs review 10 months ago
  • 🇮🇳India viren18febS

    I have updated the info file & commit the changes, please review.

  • First commit to issue fork.
  • 🇫🇷France netsliver Chelles

    Hello, new patch for all libraries

  • 🇹🇷Turkey emircanerkul Turkey

    Attaching branch changes as a diff file.

Production build 0.71.5 2024