Problem/Motivation

  • #3136604: Update to jQuery 3.5.1 updated Drupal 8.9/9.0/9.1 from jQuery 3.4.1 to 3.5.1.
  • jQuery 3.5 introduced a breaking change to how HTML passed to various jQuery functions gets parsed. Prior to 3.5, jQuery attempted to parse it as XHTML, so $("<div/><div/>") would return a jQuery object containing 2 elements: each an empty div. With jQuery 3.5, jQuery parses it as HTML, which treats self-closing tags as just start tags, so that now returns a jQuery object with 1 element: a div with a child div.
  • jQuery 3.5 is more "correct", because it was incorrect to parse as XHTML within a document whose content type is "text/html". However, there's a lot of old JS out there that's potentially relying on jQuery's prior, incorrect, behavior.
  • $("<div/>") is a common idiom in jQuery. And not just for divs, but for many other element types. Fortunately, this isn't broken, because for a single element like this, there's no ambiguity. The ambiguity only occurs when there's something that follows a self-closing tag.
  • Some examples of code that is affected by this change though are:
  • SA-CORE-2020-002 included BC for this for Drupal 7.x, 8.7.x, and 8.8.x. However, that's because those are Drupal versions that aren't on jQuery 3.5, and because BC is extra important for patch releases. We could choose to forward port some of this BC into Drupal 8.9+ if we want to, but then we'd be reverting to behavior that is technically incorrect (parsing text/html content as XHTML).

Proposed resolution

Given the examples above, I don't think we need to add BC in core. We could potentially do it in contrib. However, if we discover examples that are affecting more sites, then perhaps we do want to add the BC in core. Hence this issue, to collect more feedback.

Remaining tasks

Discuss.

User interface changes

API changes

Data model changes

Release notes snippet

Comments

effulgentsia created an issue. See original summary.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev
nod_’s picture

Status: Active » Closed (outdated)