active-link.js should use CSS.escape

Created on 24 October 2023, 8 months ago
Updated 13 May 2024, about 2 months ago

Problem/Motivation

We see a lot of javascript errors, thrown from the querySelectorAll call in active-link.js, when the URL contains characters that are not allowed by querySelector.

```
Uncaught DOMException: Failed to execute 'querySelectorAll' on 'Element': '[data-drupal-link-system-path="documenten"]:not([hreflang])[data-drupal-link-query='{"id":"848","scroll-to":"[data-document-id='848']"}'],[data-drupal-link-system-path="documenten"][hreflang="en"][data-drupal-link-query='{"id":"848","scroll-to":"[data-document-id='848']"}']' is not a valid selector.
```

Steps to reproduce

On a local Drupal 10.1 installation, navigate to this path:

/?scroll-to=%5Bdata-document-id%3D%27848%27%5D

Open the browser's dev tools, observe the errors.

Proposed resolution

Wrapping the selectors.join(',') call in CSS.escape() fixes the issue.

🐛 Bug report
Status

Closed: duplicate

Version

11.0 🔥

Component
Javascript 

Last updated about 9 hours ago

Created by

🇳🇱Netherlands roderickgadellaabsl

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024