Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In Drupal 7, -processed was deprecated instead of .once().
http://drupal.org/update/modules/6/7#jquery_once
In Drupal 8, we're still using -processed.
core/misc/drupal.js
core/misc/ajax.js
core/misc/tabledrag.js
core/modules/openid/openid.js
core/modules/color/color.js
core/modules/file/file.js
We should not do that any more.
Comment | File | Size | Author |
---|---|---|---|
#31 | i1473314-d7-do-not-test.patch | 4.51 KB | attiks |
#25 | use-of-function-in-js-core.txt | 112 bytes | litwol |
#23 | drupal-ajax-once-namespace-too-short-1473314-1.patch | 574 bytes | litwol |
#22 | drupal-ajax-once-namespace-too-short-1473314-1.patch | 1.13 KB | litwol |
#20 | drupal-1473314-20.patch | 4.52 KB | tim.plunkett |
Comments
Comment #1
nod_Don't see other incorrect uses beside in those files. Not really a major task either. Much more important, and broken, things to take care of in JS-land.
Comment #2
nod_here it is, i'll have to reroll 2 or 3 patches because of this one so that'll be nice if it doesn't takes forever to gets this in.
Comment #3
nod_stuff changed since last month, will need a reroll.
Comment #4
tim.plunkettIt was #1419968: Replace $('selector', domelement) with $(domelement).find('selector') that broke it, here's a reroll.
Comment #5
nod_thanks :)
All good, i'd RTBC if I could…
Comment #6
tim.plunkettTalked with litwol about this on IRC, the color and openid parts are busted. I think he'll be following up.
Comment #7
litwol CreditAttribution: litwol commentedand ajax selector part is busted :). artifact from d7 days that was not caught. will follow up shortly. need to write test module :-\
Comment #8
nod_the color thing was backward, but the rest is working, can you describe the issue? looks like it works to me.
Comment #9
litwol CreditAttribution: litwol commentedSee my patch for test module i wrote to illustrate where drupal.behaviors.ajax.attach work as expected and when not.
Be advised that this module is showing pre-patched ajax.js behaviors. Do not apply your patch from above to it when testing.
I've left comments in the module file that explain the problems.
Comment #10
litwol CreditAttribution: litwol commentedFirst work in progress patch to fix bad selector/killswitch.
This patch fixes discrepancy between element_settings.selector and base variables. With introduced changes .once() killswitch now works as expected.
Strictly speaking the "base" variable that we keep passing around (such as into Drupal.ajax(base,...)) is rather useless when compared to element_settings.selector. However i left base in for the time being to reduce the scope of the patch, which originally is just making core switch to .once() uniformly. We should open another issue to reexamine use of "base" (and ajax.js) in general for "makes no sense" functionality.
Comment #11
litwol CreditAttribution: litwol commentedAttached patch is the merge between #8 and #10.
@todo:
fix original logic behind openid.js
Lets tackle Drupal.ajax afterwards and make it more flexible/useful: #1533366: Simplify and optimize Drupal.ajax() instantiation and implementation
Comment #12
litwol CreditAttribution: litwol commentedAttached patch is continuation of #11, with fix to the openid.js. ("fix" in a sense that original patch broke logic flow with straight convert to .once() killswitch. this fix uses .once() while maintaining old logic flow).
Comment #13
nod_works for me!
I got so confused about this patch and the final working patch looks nothing like mine so I'm taking the liberty to rtbc it. We talked for hours about this on IRC i don't think we missed something.
Comment #14
attiks CreditAttribution: attiks commentedWorks for me as well, great work.
Attached a patch for Drupal 7 so this can get backported.
Comment #16
tim.plunkettAny D7 patches should be suffixed with -do-not-test until this is into D8.
Back to RTBC for #12.
Comment #17
attiks CreditAttribution: attiks commentedsorry about that.
Comment #18
catchThanks! Committed/pushed to 8.x, moving to 7.x for backport.
Comment #19
tim.plunkettWondering if #14 will just work now.
Comment #20
tim.plunkettNope, needed to be reuploaded. Just retitled version of @attiks's patch in #14.
Comment #21
sun1) Wrong .once() identifier 'drupal-ajax' instead of 'ajax'. This means that dependent JS and CSS no longer applies.
2) This is a change in behavior, which I do not see being discussed in this issue, so it looks like it was unintentionally overlooked: The Ajax behaviors were previously attached to #base instead of .selector. This means that Ajax behaviors are now bound to the .selector instead of the triggering #base. Which in turn means that whenever an unprocessed .selector appears in the DOM, Ajax behaviors are attached to it. The previous behavior potentially did not re-execute, because the primary condition was on #base.ajax-processed, regardless of whether there is a .selector or not. This needs more discussion and in-depth reviews from Ajax framework authors and maintainers.
3) While touching that selector logic, we could have fixed the missing usage of context as well. However, that also requires testing and discussion.
4) Missing space after "function" in (anonymous) function().
Missing space after "function" in (anonymous) function().
Comment #22
litwol CreditAttribution: litwol commented1. I've attached patch to revert back to original "ajax"[-processed] lock as it was dev artifact evaluating whether it is better to namespace once() locks with "drupal-" or not. I think simply "ajax" is too short and may conflict with other css/js libraries, but then again.. maybe not.
2) This was deliberate change, rather than overlooked. See patch in #9 that illustrates the /bug/ in d7 ajax.js attach behaviors. it was explained to me that ajax framework was originally intended for form api (which provides #base, always?), and that was good for the time. Now we provide ajax support for anything (links, divs, map area, images, buttons, ...anything...) that can be interacted with (clicked, for sake of argument) or more advanced have "interaction" event triggered by some other javascript (that is client/project specific). Assuming that a to-be-ajax element always to have #base is simply wrong, that is artifact days. Perhaps core doesn't make full use of this, but that does not mean project/client specific tools are not being built that rely on the more flexible element_setting.selector (i do, hence the test module patch in #9).
3) elaborate please. are you referring to something like this: http://drupal.org/node/1509540#comment-5818186 ?
4) Fixed in attached patch.
Comment #23
litwol CreditAttribution: litwol commentedI realize now i'm not sure what sun meant in his 4th point. I've grepped other js files in ./core/misc/*.js and use of anon "function() {" seems to be identical. Elaborate please. in the mean while i'm attaching patch that takes care of first point from http://drupal.org/node/1473314#comment-5887008
Comment #24
tim.plunkettI think he means it should be
function ()
Comment #25
litwol CreditAttribution: litwol commentedSee file. thoughts? I am all in favor of "standardizing" this. However this is scope creeping on the original issue. please do not high jack. Open new issue for this "cleanup".
Comment #26
attiks CreditAttribution: attiks commented1/ patch in #23 is looking good
2/ are there any examples that rely on the old behavior, i skimmed through core and couldn't find anything that can break with the change from #12, but it can just be me
3/ i think this can be done in a follow up issue
4/ i think we better clean this in a separate patch
Comment #27
nod_@litwol, you're catching jquery with your command. I find 5 use for our code in this folder, the rest is jQuery/UI
In all core files (including the 5 from before): 14 times.
for
function ()
with a space: 190. Needs to be fixed in this patch.Comment #28
sunre 2) It's suboptimal to squeeze in a fix for a functional bug into a code clean-up patch like this. It also means the fix is not backed by automated tests (if possible). After looking at the example module code in #9, the change looks correct, but I'm not 100% sure. This needs extensive testing (with existing contrib modules) and reviews before it can be backported.
re 3) I meant to change
$(selector)
into$(selector, context)
. However, let's do that in a separate issue.re 4) See JavaScript coding standards section about functions (anonymous functions).
Comment #29
attiks CreditAttribution: attiks commented@sun: i created a test for the new patch, so failing for the moment: http://testswarm003.h001.attiks.com/drupal-ajax-1473314?testswarm-test=t... but i do understand your concern.
Do you (or anyone else) knows about contrib modules that might break?
Comment #30
attiks CreditAttribution: attiks commentedI tried testing this (on drupal 7, patch attached) with views, ctools, panels but everything behaves the same as without the patch.
all editing works the same as without the patch
view with exposed filter + pager and ajax enabled
panel
mini-panel
page
ctools AJAX demo
Comment #31
attiks CreditAttribution: attiks commentedpatch of #30
Comment #32
nod_the open id part of it was fixed separately.
Comment #33
nod_Not anymore. Fixed by jquery once update to 2.0
Comment #34
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI guess this is still worth backporting, if it won't break anything.