Fix round-off error in Vector's collapsibleTabs.js
authorOri Livneh <ori@wikimedia.org>
Thu, 19 Dec 2013 07:14:10 +0000 (23:14 -0800)
committerOri Livneh <ori@wikimedia.org>
Thu, 19 Dec 2013 07:14:10 +0000 (23:14 -0800)
commit1a09f15671f91826d33421a12decd2c4b40906af
tree9cf32975fc70d382fcb454f2aecb76a5f9d62cbd
parent65a304c44451d0a62d01b809f3ef24c921286702
Fix round-off error in Vector's collapsibleTabs.js

Values returned by jQuery's .width() are rounded off, whereas offset values
computed with .offset() are not. As a result, if the window is sized just
right, collapsibleTabs.js will decide it has enough room to expand a tab when
it really doesn't. It will then detect the tab overlap caused by squeezing in
an additional tab and collapse it. It gets stuck in an infinite loop doing
that.

We could replace usage of $(el).width() with el.getBoundingClientRect().width
and thereby make the width calculations precise, but I noticed that jQuery is
nervous enough about the availability of getBoundingClientRect that it includes
a check to make sure it is not undefined. Rather than run the risk of a
ReferenceError, we can simply require an additional extra pixel of space before
we decide to expand anything.

Bug: 58682
Change-Id: Ib2096894619b8343735de482ee8bfa20a7cd0f48
skins/vector/collapsibleTabs.js