Needs work
Project:
Color backport
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
24 Aug 2012 at 15:26 UTC
Updated:
26 Aug 2022 at 11:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nod_color.js
there is a #preview.once in a loop, take it out.
use .on everywhere (works with delegation).
the focus function unbind and rebind events, should be delegated.
lock update looks overly complicated.
Try decoupling everything with custom events in some places (updating related colors for example).
preview.js
Select elements first, then use them somewhere. Don't reselect from the ID, select the id then .find() what's needed.
Comment #2
oxyc commentedA starting point just optimizing selectors and delegates basically. No refactoring whatsoever yet.
Comment #3
jelle_sChanging issue status
Comment #4
oxyc commentedLots of this really need a rewrite and the id-selectors don't need to be scoped. I'll look into cleaning this up later this week unless someone else gets there first :)
Comment #5
seutje commentedFirst! :D
Only adding a slight optimisation because it seems like all the other
$form.find('#id')calls seem to depend on the outcome of a.once()call. Probably able to optimize some more, but I don't have time to investigate possible repercussions right now.Comment #6
jelle_sHad a quick look-through. These are all selectors selecting by id, so I think the .find() is unnecessary here?
Comment #7
kiphaas7 commentedInvestigate if adding basic events and detach makes sense, as described in #1763812: [META] Provide complete attach/detach with basic events
detach at least?
Comment #8
seutje commented@#6: Did you check if they depend on that
.once()call, cause I think they do. Perhaps they should be wrapped in a conditional that checks if$formis populated and then just runs it on the regular ID?Comment #9
kiphaas7 commentedI don't believe
$(context).find(id)should be changed to$(id). Yes, 90% context === document, but the other 10% it doesn't, which means$context.find(id).lenghtcould equal 0, while$(id).lengthmost probably always return 1.One could argue that the
.once()takes care of any double behavior happening, but if that's the case this should be documented somewhere. As this is a departure from D7 js conventions. Also, I'd think that$(context).find()is a bit more flexible than having to rely on.once().Comment #10
jelle_syou're right, I forgot about that.
$(context).find(id)is better indeed.Comment #11
nod_tag
Comment #12
markhalliwellFair enough, but this should then be part of the color.module component (also for our exposure) since it belongs to a specific module and is not standalone core JS. Added issue references.
Comment #13
droplet commented5: core-1751334-5.patch queued for re-testing.
Comment #15
internetdevels commentedHi, added new patch, previous patch can't be applied. :)
Comment #16
nod_JSHint error about indentation at:
Other than that, it looks good.
Comment #17
longwaveComment #18
rteijeiro commentedRe-rolled!
Comment #19
andriyun commentedPatch is outdated
Comment #20
drintios commentedComment #21
drintios commentedComment #22
drintios commentedComment #23
drintios commentedRerolled patch, fixed merge conflicts.
Comment #24
andypostsuppose this extra line is not needed
Comment #25
drintios commentedUpdated patch, cleaned with eslint.
Comment #26
droplet commentedwe don't do other code change in clean up
Comment #27
droplet commentedComment #28
vprocessor commentedComment #29
vprocessor commentedHello guys,
droplet, I removed this strings in new patch, diff & patch attached
Comment #30
vprocessor commentedComment #31
vprocessor commentedComment #32
andypostNot sure about scope but variable renames looks reasonable
Let's get maintainers feedback
Comment #36
droplet commentedLet's do it at ES6 or at least with a JS test covered.
Comment #40
andypostComment #48
quietone commentedColor has been removed from core, #3270899: Remove Color module from core.