Problem/Motivation

Console errors in Drupal 11.1.3 saying "$.trim is not a function"

Steps to reproduce

jQuery trim() API has been deprecated in jQuery 3.5 and Drupal 11 uses jQuery 4

Proposed resolution

Replace $.trim with native trim() JS function

Remaining tasks

User interface changes

API changes

Data model changes

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

daniel korte created an issue. See original summary.

daniel korte’s picture

Assigned: daniel korte » Unassigned
Status: Active » Needs review
uttam’s picture

I have reviewed the changes and confirmed that it correctly replaces the deprecated $.trim() function with JavaScript’s native .trim(), which is fully compatible with jQuery 3.5+ and the modern browser environment used in Drupal 11. The change does not alter the core functionality, as .trim() provides the same behavior as $.trim(), ensuring that the text value is properly trimmed before processing.

After testing from the branch 3510732-.trim-is-not, I tested the character counting functionality in text fields, and everything works as expected without any errors. The update does not introduce any regressions, as .trim() is widely supported in modern JavaScript. Since the fix is correct and verified, I am moving this issue to RTBC.

uttam’s picture

Status: Needs review » Reviewed & tested by the community
mably’s picture

Fix included in the following issue: #3527955: Switch to Vanilla JS.

Any feedback will be greatly appreciated.

mably’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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