Problem/Motivation
In core/misc/ajax.js there are two functions marked as removed from Drupal 10 that still exist.
They are ajaxWrapperMultipleRootElements & ajaxWrapperNewContent. In core itself, the only usage of these files are in the ajax.js file & in their associated test.
from catch in the duplicate issue:
They were 'deprecated' in Drupal 8.6.0 before we had a JavaScript deprecation API. We need to actually deprecate them, so they can be removed. Should probably be deprecated in 8.6.0 for removal in 11.0.0 at this point. https://www.drupal.org/node/2940704
Steps to reproduce
Review core/misc/ajax.js and see the deprecations.
Proposed resolution
Remove the deprecated code.
Remaining tasks
Postponed on 12.x branch.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|
Issue fork drupal-3352549
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
Comment #3
danielvezaUpdated the deprecation to 11.0 following advice from @xjm
Comment #4
smustgrave commentedGood cleanup
Comment #5
nod_Let's take care of the todo in this issue too and add a deprecation warning. See https://www.drupal.org/node/3082634
Comment #6
danielvezaAdded the deprecation errors, I think I've done it right by adding the returns but it would be good to get some eyes over it
Comment #7
nod_code looks good, some linting issues left
Comment #8
sagarchauhan commentedFixing linting issues.
Comment #9
sagarchauhan commentedComment #14
quietone commentedThe MR is now against 11.x.
Comment #17
quietone commentedThere are two issues for this work, the other is #3301204: Properly deprecate ajax.js methods. Although the other is older this one has an MR so, lets continue work here. Also, adding credir
Comment #18
quietone commentedComment #19
catchThere are dozens of JavaScript test failures here, but from a quick scan, it looks like this deprecation might be all of them:
Comment #20
longwaveThe issue is this code, which triggers the deprecation on every Ajax insert:
I don't think the current deprecation is going to help anyway. The change notice tells you to override the method if you want to change the behaviour; if you do this then the deprecation we add here won't be fired - in fact it's only fired if you *don't* override it, which is the wrong way round?
Comment #21
longwaveMaybe what we need to do is:
Drupal.theme.ajaxWrapperNewContentandDrupal.theme.ajaxWrapperMultipleRootElementsDrupal.AjaxCommand.insertifDrupal.theme.ajaxWrapperNewContentexists then:Drupal.theme.ajaxWrapperMultipleRootElementsexists then issue another deprecationDrupal.theme.ajaxWrapperMultipleRootElementsdoesn't exist, define it (because the first theme function might call it)Drupal.theme.ajaxWrapperMultipleRootElementsexists then issue a deprecation and use it?Or, decide this is too complicated, and just drop it all from Drupal 11 without any deprecations, as we deprecated this several years ago and the code mentions removal from Drupal 9 etc, so in the event anyone was overriding this they have had plenty of notice anyway.
Comment #22
catchThis is very appealing and I think we should do it. We can always try to improve the 10.x deprecations if it turns out to be a problem, but it's also quite possible no-one is relying on it.
Comment #23
longwaveIt's still not clear what to do about the multiple root elements case; this is the breaking change.
@lauriii in #736066-357: ajax.js insert command sometimes wraps content in a div, potentially producing invalid HTML and other bugs:
However, we still haven't triggered that warning, and there may be users relying on the div wrapper around multiple elements.
So, new proposal:
Drupal.theme.ajaxWrapperNewContentonly when the.length > 1condition is true. If you were overriding this as per the change record, we assume you knew what you were doing; either you were adding divs back everywhere (but we told you this was going away), or you were overriding the multiple divs wrapper, and your code will be obsolete soon.Comment #24
longwaveRebased MR!3784 against 10.3.x and implemented #23.
Comment #26
longwaveAlso opened MR!7670 for the removal in Drupal 11.
Comment #27
longwaveSome tests failing on both MRs.
Comment #28
andypostComment #30
finnsky commentedSeems tests need deeper rework.
Comment #31
damienmckennaThe merge requests need to be updated to the latest changes on their respective branches.
Comment #33
finnsky commentedWe need align with
https://www.drupal.org/project/drupal/issues/3238870
Comment #34
quietone commentedThe deprecation was updated so this code would be removed in Drupal 12.0.
Comment #36
andypostComment #37
finnsky commentedRebased. Please review!
Comment #38
finnsky commentedComment #39
smustgrave commentedAppears like a good removal.
Comment #40
catchDiscussed this with @longwave. We both think it's OK to go ahead and remove this without the tricky deprecation layer, 8.6 was a very long time ago.
However there are at least two test failures in the latest pipeline that look very related (AJAX test + one performance test).
Comment #41
longwaveComment #42
smustgrave commentedJavascript errors appear to be valid to the change.
Comment #43
smustgrave commentedForgot about this one and was doing deprecation removals in #3575462: Remove deprecations from themes and misc and hitting the same test failures.
Comment #44
smustgrave commentedComment #45
smustgrave commentedFixed 1 test but still not sure about testBlockFilter
Comment #46
smustgrave commentedStill don't have a fix but the bug is that filtering on layout builder doesn't work at all now
Comment #47
smustgrave commentedI’d like to propose we don’t do this lol. It breaks layout builder filtering so may be a fair assumption it’ll break a contrib module. But reason I’m proposing we skip is because htmx will replace Ajax and we can eventually delete this file
Comment #48
quietone commentedNot finished for beta so moving to next major.