mirror of
https://github.com/zulip/zulip.git
synced 2025-10-31 20:13:46 +00:00
Fix outerHeight to OR with 0 to not produce NaN.
This is an issue where in jQuery v3 the result of outerHeight on a node that doesn’t exist is now “undefined” rather than “null”, which means it will no longer cast to a Number but rather NaN. For this, we create the safeOuterHeight and safeOuterWidth functions to safely return a result (or 0). This is a better solution than manually going to each instance and ORing it with 0 for type safety. https://stackoverflow.com/questions/41454285/jquery-outerheight-returns- undefined-instead-of-null
This commit is contained in:
committed by
Tim Abbott
parent
ac4ac63353
commit
d01549e8e3
@@ -9,7 +9,7 @@ $(function () {
|
||||
function scrollbarWidth() {
|
||||
$('body').prepend('<div id="outertest" style="width:200px; height:150px; position: absolute; top: 0; left: 0; overflow-x:hidden; overflow-y:scroll; background: #ff0000; visibility: hidden;"><div id="innertest" style="width:100%; height: 200px; overflow-y: visible;"> </div></div>');
|
||||
|
||||
var scrollwidth = $("#outertest").outerWidth() - $("#innertest").outerWidth();
|
||||
var scrollwidth = $("#outertest").safeOuterWidth() - $("#innertest").safeOuterWidth();
|
||||
|
||||
$("#outertest").remove();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user