Problem/Motivation
In #3052002: [meta] Replace JQuery with vanilla Javascript in core and several other places, Tabledrag was mentioned as one of the larger obstacles to removing jQuery from core. An issue to work on that can help move the jQuery removal efforts forward, and it is a large enough task that it will likely surface many additional tasks needed for removing jQuery
Steps to reproduce
Proposed resolution
Remove all jQuery usage from Tabledrag other than once() and event handling, which have their own issues: #2402103: Add once.js to core #3176441: JavaScript event handling without a full jQuery dependency.
Also refactor code that extends on Tabledrag as much as needed in order for it to work with no-jQuery tabledrag.
For the time being, suppress the tests in Claro as getting them to work would require extensive refactoring, yet that refactoring will be largely unnecessary when #3083051: Refactor tabledrag when core issues are resolved lands.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3177355-10-9.4.x.patch | 213.56 KB | tom konda |
| #8 | interdiff_6-8.txt | 1.32 KB | bnjmnm |
| #8 | 3177355-8.patch | 213.4 KB | bnjmnm |
| #6 | 3177355-6-REROLL.patch | 212.08 KB | bnjmnm |
| #2 | 3177355-2.patch | 213.98 KB | bnjmnm |
Issue fork drupal-3177355
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 #2
bnjmnmThis removes all jquery use from tabledrag other than event handling and once(). Module code that modifies tabledrag may still have jquery. The refactoring there was limited to what was neccessary for it to work with the modified tabledrag, as the patch size is already quite daunting.
A grep through the patch for @todo jquery will return several items that will likely need to be addressed as part of removing jquery, but is not in the scope of this issue. Many followups will soon be created based on these.
Comment #3
bnjmnmComment #5
nod_Need reroll after prettier update.
This is a significant change, I would keep Drupal.tableDrag around and make it a helper to initialize a tabledrag. A bit like we did with Drupal.ajax / Drupal.Ajax.
The structure of the object was changed also so any script extending the tabledrag will have to be revised.
I think we need a summary of the object structure before/after to see how much it could impact contrib.
That's a few methods we still need from jquery, might want to start putting them in a dedicated file and see how much we still need across the different scripts (since a file/library by method might be overkill)
In any case, happy to see this! always a hard script to get into, thanks :)
Comment #6
bnjmnmRe #5
I figured we would either need a BC shim or make the vanilla tabledrag available as a module + trigger deprecation notices like we are doing in #3076171: Provide a new library to replace jQuery UI autocomplete. When I created this issue, I didn't prefer one option over the other and figured working on this patch would help me figure it out. I'm leaning towards the module option as working on this has me doubting the feasibility of bridging the jQuery/vanilla tabledrags. I'm curious if you have any concerns about the module approach.
Agreed, I have @todo items for these indicating that they are probably better to add globally. I wasn't entirely sure what jQuery methods we'd need to hold onto, and I thought working on this issue would help expose what followup(s) would be needed (there are several polyfill issues I need to make as well).
Switching to NR to turn on tests, but clearly this isn't the final patch 😊
Comment #8
bnjmnm#6 had a missing polyfill, which caused the fails in #6
Comment #11
tom kondaI tested patch #8 against the commit 1a5cc0d9ab68d8c7b22143c4642a691365171cd1 and a following "Uncaught TypeError" occurs on block region changing.
The Drupal.TableDrag.row() method isn’t defined as static method but it is called from block.js without instance creation.
Comment #13
tom kondaFix patch #8 to support 9.4.x branch.
TableDrag.prevAll()in field_ui.es6.js.Comment #14
tom kondaI think this issue should be better to change target version to 10.0.x. Because IE 11 doesn’t support :scope: pseudo class and no more fix about this according to #3176438: IE11 JS does not support the :scope pseudo-class.
If it changes target version, need to remove IE 11 compatible code from the existing patch.
Comment #19
tom kondaReroll a patch for 11.x branch and create the MR 7672 as draft.
Some of functional JavaScript tests are failed, so need to resolve.