From 84c223eb82bd9b62adc14f455324699650ce2eb4 Mon Sep 17 00:00:00 2001 From: Pat O'Callaghan Date: Tue, 26 Feb 2013 11:43:06 +1300 Subject: [PATCH] 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". --- js/jquery.slabtext.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/jquery.slabtext.js b/js/jquery.slabtext.js index 278385c..86bfb84 100644 --- a/js/jquery.slabtext.js +++ b/js/jquery.slabtext.js @@ -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); \ No newline at end of file +})(jQuery);