This is a repeat of https://www.drupal.org/project/eu_cookie_compliance/issues/3277316. This problem was supposed to be fixed but is apparently broken again. When updating the module from v1.19 to 1.21, the body class is no longer applied after the user makes their consent selection.

I think the problem still in js/eu_cookie_compliance.js. Line 26 makes reference to the containing element, so I'm not sure why there is an $.each() loop with a function argument of element. Using a console.log() statement, the value of element in the loop is 0; the value of this is the actual containing element (body by default).

If I replace $(element) with $(this) on line 66, the class is properly applied.

I don't fully understand the difference between the $.each loop beginning line 26 and the forEach loop on line 71, so I'm not sure if the same fix would work on line 108. However, the element argument in each loop appears to be only used for that class assignment.

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

aaronpinero created an issue. See original summary.

aaronpinero’s picture

aaronpinero’s picture

Issue summary: View changes
svenryen’s picture

Thanks for the report! I'll have a look.

  • svenryen committed 81d4136 on 8.x-1.x
    Issue #3309240 by svenryen: Regression (again): Body class not added...
svenryen’s picture

Status: Active » Fixed
svenryen’s picture

Thanks. I can confirm you're right. The class seems to be applied correctly if we replace element with this.

Status: Fixed » Closed (fixed)

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