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.
Problem
- The JavaScript of the Simpletest UI relies on all test information to be duplicated into JavaScript settings, which ~duplicates the total HTML page size.
Proposed solution
- Remove those JS settings entirely and properly use jQuery instead.
Comment | File | Size | Author |
---|---|---|---|
#10 | interdiff.txt | 795 bytes | sun |
#10 | test.js_.10.patch | 10.15 KB | sun |
#3 | interdiff.txt | 1.03 KB | sun |
#3 | test.js_.3.patch | 10.07 KB | sun |
#1 | test.js_.1.patch | 10.2 KB | sun |
Comments
Comment #1
sunAttached patch re-implements all the existing behaviors without unnecessarily relying on those JS settings.
Comment #2
nod_We should use a data attribute to select this.
This should be using toggleClass() instead of the if / else. Very glad to see the animation go.
Comment #3
sunChanged to use
toggleClass()
— although in this particular case,toggleClass()
makes the logic significantly harder to understand.The .simpletest-group class on the table row is also used for styling purposes, so I do not think it makes sense to change that into a data attribute.
Comment #4
nod_We want to decouple JS from styling so not using a class let themers do whatever they want. Probably not needed here but it's to keep consistent (this is agreed with CSS people and getting rolled out... eventually).
If you name the variable
expanded
, toggleClass makes a bit more sense (to me anyway).+expand
really not a fan of that but whatever, simpletest has never been the best script around and if people take it as an example they're pretty doomed :pComment #5
sunYeah, I can see that using a data attribute would make sense elsewhere... but in this case, the HTML markup (table) + JS + CSS is pretty tightly coupled... and very unlikely to be customized or overridden by anyone ;-) — so let's keep it simple? :)
First, I actually had
expanded
(or ratherisExpanded
), but that made thetoggleClass()
calls even more confusing, since all of them would be negated:Therefore, I went with the non-negated
expand
(which is meant to read as "do expand").Anyway... the primary objective here is to get rid of the completely duplicated test list in JS settings. Anything else? :-)
Comment #6
nod_I'm happy enough the animation is gotten rid of.
Comment #7
alexpott$test_id and $test_checkbox_id are no longer needed.
This return is unnecessary.
Comment #8
nod_The retun stops the iteration, which is good because there are a lot of checkboxes. Getting out earlier is what we'd want.
Comment #9
alexpott#8 sure - but is the FALSE necessary?
EDIT: Answering my own question - https://forum.jquery.com/topic/breaking-the-each-loop - indeed it is.
Comment #10
sunRemoved obsolete variables from SimpletestTestForm.
Comment #11
webchickOk, looks like Alex's feedback was addressed.
Committed and pushed to 8.x. Thanks!