d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.
https://d3js.org/d3-zoom
ISC License
501 stars 144 forks source link

Variable used before initialization #235

Closed 277hz closed 3 years ago

277hz commented 3 years ago

https://github.com/d3/d3-zoom/blob/84a5e7b08b28fc100f80a5facefe7d52d6354ee2/src/zoom.js#L274-L275

While not generally an issue as d3-selection pointer resolves currentTarget by itself, event.currentTarget could technically change in between due to being a getter function.

Respective code was added by Fil@3156eb0ceb23446f8dafc9824a2de91950f52dd4.

Fil commented 3 years ago

leaves me wondering if we should do

p = pointer(event), currentTarget = event.currentTarget,

or

currentTarget = event.currentTarget, p = pointer(event, currentTarget),

277hz commented 3 years ago

@Fil I stumbled upon this while using some older obviously buggy version of Chrome. Your second suggestion fixed it for me though.