Problem/Motivation
#2533498: Update jQuery to version 3 is a Critical task to update jQuery to version 3, ideally before 8.4-alpha.
In jQuery 3, $('#') throws a syntax error. This is responsible for the test failure in #2533498-79: Update jQuery to version 3.
The failure is triggered by the code and test added in #2531700: Fragment links to children elements in closed grouping elements don't work. Specifically, this line in form.js:
$target = $('#' + location.hash.substr(1));
When the location hash can be simply '#', which appears to be set to that in FormGroupingElementsTest::testDetailsChildVisibility()'s:
$reset_js = "location.replace('#'); jQuery('details').removeAttr('open')";
Proposed resolution
Not sure if the test is wrong for setting that location or if form.js is wrong for not checking for that before invoking $().
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | interdiff-16-19.txt | 643 bytes | effulgentsia |
| #19 | 2898261-19.patch | 3.78 KB | effulgentsia |
| #16 | interdiff-7-16.txt | 853 bytes | effulgentsia |
| #16 | 2898261-16.patch | 3.78 KB | effulgentsia |
| #7 | core-js-form-error-2898261-7.patch | 3.91 KB | nod_ |
Comments
Comment #2
effulgentsia commentedComment #3
droplet commentedComment #4
dmsmidtI agree catching this use case in form.js.
Often enough I see an empty fragment in URLs.
Patch looks good, just one question, if we add these conditions shouldn't we also do the same for:
$target = e.currentTarget.location ? $(e.currentTarget.location.hash) : $(e.currentTarget.hash);?I'm not sure it can potentially be #. Could someone check?
Comment #5
droplet commentedIt should look like this if you ask me.
Comment #6
larowlanCombined this with #2533498: Update jQuery to version 3 in comment 83 to see if it fixes fails with jQuery 3.x.
Added @droplet to issue credits over there.
Comment #7
nod_Put back the support for click on links when the hash is already in the URL. Used
triggerinstead of the .focus() alias function. Removed the extra parameter to the settimeout, it's not used and not crossbrowser.Comment #8
droplet commentedHmm.. So #5 contains a bug. It takes the old hash and the test case didn't catch it.
Just my own curiosity, when will `e.currentTarget.location` has value?
** Another bug, we should verify the href is current URL. (can be follow-ups)
Comment #9
nod_Not sure, didn't want to track it down so left it there. Possibly we could get rid of it.
Comment #10
effulgentsia commentedFor what it's worth, I like #7 as the proper scope for this issue. I think #8 and #9 can be left to a follow-up issue. Anything else needed for this to be RTBC'd?
Comment #11
cilefen commentedWould location have a value here?
Comment #12
cilefen commentedDuh - ignore.
Comment #13
GrandmaGlassesRopeManAny reason we're changing this? Feels out of scope for this patch.
Comment #14
effulgentsia commentedRe #13, I can see the argument for it being out of scope for this issue, but it also looks like a no-op cleanup to me...
Within ES6:
Is there any difference between a const that's a function and a function?
Within the transpiled JS:
This looks like a pure coding style cleanup to me, or is there any actual functionality to assigning a function to a variable of the same name?
So long as it's a no-op or has a justification, I'm fine with it staying in this patch. I'd also be fine with that bit getting moved to a separate issue. Either way, I'd love to still commit both this and #2533498: Update jQuery to version 3 before the alpha freeze (in 10 hours) if they can still make it to RTBC by then.
Comment #15
GrandmaGlassesRopeMan@effulgentsia
We already had this discussion in #2531700: Fragment links to children elements in closed grouping elements don't work.102. I'd personally prefer we not attempt to make this change here and if we really want to have a discussion, let's move it to another issue.
Comment #16
effulgentsia commentedRe #15, yes, if there's any contention around it, then we should leave it alone and discuss it elsewhere. So this reverts the out of scope line.
Comment #17
effulgentsia commentedUnticking the credit checkbox for myself, because all I did in #16 was revert a line to how it is in HEAD.
Comment #18
effulgentsia commentedFor getting a test run with #16 in the presence of jQuery3, I posted a combined patch in #2533498-88: Update jQuery to version 3.
Comment #19
effulgentsia commentedThis also restores HEAD's semicolon at the end of the function assignment. Tests pass with or without the trailing semicolon, but it just makes sense to add the semicolon back in, since that's how it is in HEAD and elsewhere in multiline assignments. Sorry to have missed that when uploading #16.
Comment #20
nod_Changed it for consistency, the rest of the file has regular function declaration.
As a general rule I dislike anonymous functions and seriously question the use of arrow function when the function body is multi-line (and needs to be wrapped in {}).
@drpal: I don't see the discussion all i see is #2531700-106: Fragment links to children elements in closed grouping elements don't work.
Anyway, doesn't matter.
Comment #21
effulgentsia commentedAll feedback given on this issue has been addressed, and my only contributions were to revert pieces, not write any original code; therefore, RTBC! I'm about to go to sleep, so leaving it to committers in other timezones to decide if this can still make it in before alpha freeze.
Comment #22
andrewmacpherson commentedTaking this for manual testing. I think it's good idea to double check patches like this, because well-intentioned JS changes have led to a11y regression in the past.
Comment #23
droplet commentedAny examples? I afraid this message will confuse committers in the future JS changes. Most of JS usually the additions to new changes in UI which provides extra functions but not remove existing features.
Comment #24
dmsmidt@droplet #23, one example would be keyboard navigation for drag-and-drop ordering situations, that broke in the past.
@nod_ #20, I had a discussion with @drpal about function declarations in that issue and it continued on Slack. It was based on this:
https://github.com/airbnb/javascript#functions--declarations and https://github.com/airbnb/javascript/issues/794
Comment #25
andrewmacpherson commentedDone manual testing. I went through the same scenarios as we tested in #2531700: Fragment links to children elements in closed grouping elements don't work recently where this fragment link handler was introduced. Still working fine, so still RTBC.
@droplet - I was thinking of #2574917: Regression: vertical tabs are not keyboard accessible. and #2711907: [regression] Some ajax-enabled buttons are not keyboard operable. Both of these regressions happened after issues aimed at modernizing or simplifying existing JS code. We didn't have FunctionalJavascript tests back then (and we've started simulating keyboard interaction in some) so hopefully we'll see fewer regressions like that.
Edit: The issue @dmsmidt mentioned is #2725259: [regression] Table Drag handles no longer respond to up/down arrow keys
Comment #26
andrewmacpherson commentedComment #27
droplet commentedThanks @dmsmidt & @andrewmacpherson.
Comment #29
lauriiiThanks for taking the time to manually test this and confirming that this works. The code changes look good for me. We will also get some test coverage for this once #2533498: Update jQuery to version 3 gets committed. So this is now committed cfff720 and pushed to 8.4.x. Thanks!
Comment #30
cilefen commentedWhat about 8.5.x?
Comment #32
cilefen commentedI pushed it to 8.5.x.