In core JS files, every time
.parents() is used
.closest() is what was meant.
Begins with the current element
Travels up the DOM tree until it finds a match for the supplied selector
The returned jQuery object contains zero or one element
Begins with the parent element
Travels up the DOM tree to the document's root element, adding each ancestor element to a temporary collection; it then filters that collection based on a selector if one is supplied
The returned jQuery object contains zero, one, or multiple elements
The js present in core never use multiple elements and always add a selector to limit results to 1 element. It's used with either
parents('tr') and sometimes it just hopes there is no nested structures (tableselect/tabledrag) .
The following patch replace all occurrences of
.closest(), in the very deep HTML tree Drupal usually outputs that could mean some pretty serious performance improvement. I checked every replacement by hand, it's all still working :)
Along the way I fixed a bug in
shortcut.admin.js where "New set" wouldn't be checked when focusing the text input.
filter.js could be less complicated as the change event bubbles up, it can be catched by
PASSED: [[SimpleTest]]: [MySQL] 38,432 pass(es). View
PASSED: [[SimpleTest]]: [MySQL] 37,892 pass(es). View
FAILED: [[SimpleTest]]: [MySQL] 33,341 pass(es), 1 fail(s), and 0 exception(es). View
PASSED: [[SimpleTest]]: [MySQL] 37,023 pass(es). View
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch core-js-parents-to-closest-1400310-8-D8.patch. Unable to apply patch. See the log in the details link for more information. View