Problem/Motivation

When upgrading Drupal from 9 to 10, I get an JavaScript error that says "$.cookie is not a function". This is due to Drupal 10 not including the jquery.cookie library anymore (deprecated in Drupal 9). For more information, refer to the relevant change record.

Steps to reproduce

- Install and enable bootstrap_site_alert on Drupal 10 site.
- Open developer tools and notice the errors on the JS console.

Proposed resolution

Use js-cookie library instead of jquery.cookie.

Comments

mmenavas created an issue. See original summary.

mmenavas’s picture

Attempt to fix this issue on 8.x-1.x branch.

mmenavas’s picture

Posting new patch as the pervious one wasn't working for me.

keshavv’s picture

Status: Active » Needs review

joseph.olstad’s picture

Status: Needs review » Fixed

fixed in the 8.x-1.x branch only

Status: Fixed » Closed (fixed)

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

camslice’s picture

hi joseph.olstad, will you be released a new tag on the 8.x-1.x branch that includes this fix? the current tag 1.10.0 does not seem to include the fix.

currently my composer.json looks like this 🙃

"drupal/bootstrap_site_alert": "dev-1.x#d0be53e24c5e2632795f8822564c06604fda2cc6"

additionally, it seems that dismissed-cookies.js is throwing an error on line 14:

12 ...
13 if (cookies.get('Drupal.visitor.bootstrap_site_alert_dismissed') !== key) {
14   $('.bs-site-alert').css('display', 'block');
15  }

cookies is undefined... which can be fixed by providing a default value on line 2:

1
2  (function ($, Drupal, cookies = {}) {
3  ...

thoughts?

joseph.olstad’s picture

joseph.olstad’s picture

Status: Closed (fixed) » Active
joseph.olstad’s picture

Status: Active » Fixed
camslice’s picture

Thanks @joseph :)

Status: Fixed » Closed (fixed)

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