Permalink
Browse files

Added sanity check to prevent infinite loop

Added sanity check to prevent infinite looping of the while loop if the parentWidth is 0, e.g. parent is "display: none".
  • Loading branch information...
1 parent 260926b commit 84c223eb82bd9b62adc14f455324699650ce2eb4 @patocallaghan patocallaghan committed Feb 25, 2013
Showing with 6 additions and 1 deletion.
  1. +6 −1 js/jquery.slabtext.js
View
@@ -78,6 +78,11 @@
// Cache the parent containers width
var parentWidth = $this.width(),
fs;
+
+ //Sanity check to prevent infinite loop
+ if ( parentWidth === 0 ) {
+ return;
+ }
// Remove the slabtextdone and slabtextinactive classnames to enable the inline-block shrink-wrap effect
$this.removeClass("slabtextdone slabtextinactive");
@@ -237,4 +242,4 @@
};
});
};
-})(jQuery);
+})(jQuery);

0 comments on commit 84c223e

Please sign in to comment.