Skip to content

Commit

Permalink
Added sanity check to prevent infinite loop
Browse files Browse the repository at this point in the history
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
patocallaghan committed Feb 25, 2013
1 parent 260926b commit 84c223e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion js/jquery.slabtext.js
Expand Up @@ -78,6 +78,11 @@
// Cache the parent containers width // Cache the parent containers width
var parentWidth = $this.width(), var parentWidth = $this.width(),
fs; 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 // Remove the slabtextdone and slabtextinactive classnames to enable the inline-block shrink-wrap effect
$this.removeClass("slabtextdone slabtextinactive"); $this.removeClass("slabtextdone slabtextinactive");
Expand Down Expand Up @@ -237,4 +242,4 @@
}; };
}); });
}; };
})(jQuery); })(jQuery);

0 comments on commit 84c223e

Please sign in to comment.