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:
- Drupal core's Quick Edit, prior to us fixing that in #3136604: Update to jQuery 3.5.1.
- Some of Bootstrap's unit tests, prior the them fixing it in https://github.com/twbs/bootstrap/pull/30648.
- FullCalendar 3.0, though version 4 re-architected away from jQuery entirely.
- 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.
Comments
Comment #4
nod_