bug finding a max with letter-spacing
Opened this issue · 0 comments
usrlocalben commented
If you have negative letter-spacing, then container width() can be zero as the loop starts to find a max to bsearch from. In this case, it will exit early since it compares it against the (uninitialized) variable 'width' . The comments say that this is to "prevent an infinite loop." I'm not sure what testcase might cause that, but it appears that this code is unnecessary. If I set realWidth to container.width() and remove the infinite loop stuff then it works fine.
--- jquery.stretch.js.original 2011-09-24 22:50:22.974482000 -0400
+++ jquery.stretch.js 2011-09-24 22:28:29.274540681 -0400
@@ -63,11 +63,7 @@
min = max;
max *= 2;
container.css("font-size", max + "px");
-
- // If the width isn't changing, then avoid an infinite loop.
- var realWidth = contents.width();
- width = realWidth <= width ? idealWidth : realWidth;
-
+ width = contents.width();
} while (width < idealWidth);
} else {
max = opts.max;