As part of #1415788: Javascript winter clean-up we're cleaning up the jQuery selectors (remove duplicated code, simplify selectors).
states.js looked pretty sane to me, so I'm inclined to set this on "works as designed", but I can't ofcourse before setting this to needs review.
| Comment | File | Size | Author |
|---|---|---|---|
| #23 | selectors_clean_up-1751070-23.patch | 1.42 KB | kostyashupenko |
| #20 | 1751070-statesJS-20.patch | 1.48 KB | rteijeiro |
| #18 | 1751070-statesJS.patch | 1.49 KB | droplet |
| #5 | 1751070-states-document-cleanup.patch | 1.95 KB | rballou |
Comments
Comment #1
nod_All right, haven't seen anything obvious but I want to keep it around some more.
I'll take it out of the review list for now.
Comment #2
kiphaas7 commentedBONUS: Investigate if adding basic events and detach makes sense, as described in #1763812: [META] Provide complete attach/detach with basic events
Furthermore:
Shouldn't all those use the dot as a namespace separator, or does the ":" have some special function I'm missing? Might have something to with the comment below, but I'm actually unfamiliar with the state system.
Comment #3
seutje commentedLooks a mighty lot like event namespacing in Prototype, should probably be reversed and changed to a dot like
.on('disabled.state', fn)so themes and modules can easily unbind them all in one go.Comment #4
nod_tag
Comment #5
rballou commentedI've attached a patch below, which makes a couple minor changes to the code:
$(document)calls to a$documentvariable to reduce recalling jQuery over and overI don't particularly think these changes are necessary by any means, but may offer some (very minor) performance and maintainability changes to this code.
Comment #6
nod_Can you replace all
.bind,.click, etc with.on('event')as well? We're going for consistency :)Comment #7
rballou commentedOn it! :)
Comment #8
rballou commentedAlso changed up the event binding to use
.on(). Used$(document).on()which may need to change, so let me know.Comment #9
nod_The change line 121 shouldn't be there, it'll mess up the
e.targetvalue in the listeners and break everything :pAnd about listeners, last nitpick.
can be written as
I usually don't like much of the jQueryism but you gotta admit they made a really nice event API :)
After that I'd RTBC it.
Comment #10
nod_Comment #11
rballou commentedSounds great! Here's an updated patch with:
Comment #12
rteijeiro commentedRerolled this abandoned patch and now works :)
Comment #13
rteijeiro commentedSorry, JSHint complained about a comma and I have noticed now. Rerolled the patch again :(
Comment #14
areke commentedThe patch needs to be re-rolled once again.
Comment #15
rballou commentedI've taken a stab at the re-roll. I did ignore one change from the last patch as that seems to have changed.
The patch had:
The file is now using:
this.element.on(event, $.proxy(function (e) {Comment #16
rteijeiro commentedLet see what says the testbot.
Comment #17
star-szrThanks @rballou!
Comment #18
droplet commentedUnless it's something avoid Drupal code standard, I think the patch is fine. Even, I will close it as won't fix. The performance gain is sooo little.
#9 suggestion is too personal preference :)
https://drupal.org/comment/8183337#comment-8183337
Comment #19
manuel garcia commentedComment #20
rteijeiro commentedRe-rolled!
Comment #21
andriyun commentedPatch is outdated
Comment #22
andriyun commentedComment #23
kostyashupenkoReroll of #20
Comment #24
droplet commentedThanks.
Comment #26
catchCommitted/pushed to 8.1.x, thanks!
Since this is clean-up only and not a functional bug fix, not committing to 8.0.x.