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.
Added a scope to the select search.
Changed the selector to match the select name instead of relying on a wrapper class'.
Comment | File | Size | Author |
---|---|---|---|
#10 | core-js-selectors-book-1574620-10.patch | 491 bytes | jibran |
#4 | core-js-selectors-book-4.patch | 516 bytes | nod_ |
#2 | core-js-selectors-book-1.patch | 522 bytes | nod_ |
core-js-selectors-book.patch | 524 bytes | nod_ | |
Comments
Comment #1
nod_forgot tag
Comment #2
nod_wrong patch :/
Comment #3
droplet CreditAttribution: droplet commentedAbove patch looks good. Considering for performance, I preferred use this class.
'#attributes' => array('class' => array('book-title-select')),
Comment #4
nod_You're right. Less likely to break too.
Comment #5
droplet CreditAttribution: droplet commentedComment #6
Dries CreditAttribution: Dries commentedWhy are we making this change?
Comment #7
nod_The patch scope the search of the form input to the current vertical tab. Previously it would search from the whole document.
The previous selector was not very optimized:
.some-class-name select
will always be slower to match than.some-class-name
.I haven't run into bugs because of all that but it improves performance. I wouldn't call it micro-optimization since this is the DOM we're talking about.
Comment #8
nod_benchmark backing it up: http://jsperf.com/drupal-book-selector At least 10x faster. In chrome it's actually 100x faster.
Changing to this types of selector will make using the native querySelector much easier. Added the native selector to the benchmark, it's between 2x (opera) and 390x (chrome!) faster.
Now this is just one file, we have tens of files with the same kind of things, it sure doesn't look like it but it's an important patch.
Comment #9
Dries CreditAttribution: Dries commentedThanks for the clarifications. Committed to 8.x. Moving to 7.x.
Comment #10
jibranpatch for drupal-7
Comment #11
droplet CreditAttribution: droplet commentedIt may not safely backport to D7 directly since someone may change the class name. (minor version upgrade issue)
Comment #12
nod_We don't have the manpower to backport this kind of patches. If this gets in 7, then all the other selectors patches should get in 7 and they are going to be more invasive than this one. Can't be sure it won't break contrib and manual testing doesn't scale.
Comment #14
Manuel Garcia CreditAttribution: Manuel Garcia commented