Hotfix: loadRelatedArticles should consider existence of container element

If undefined, the offset function will return undefined.

Bug: T281547
Change-Id: I8ae3c1ee1d259c67d597a1891af029e6192008f8
This commit is contained in:
Jdlrobson 2021-04-30 15:59:41 -07:00
parent edeb38fc58
commit 80ef6cffb4

View file

@ -26,6 +26,11 @@
var readMore = $( '.read-more-container' ).get( 0 ),
scrollThreshold = $window.height() * 2;
if ( !readMore ) {
// The container is not in the HTML for some reason and cannot be queried.
// See T281547
return;
}
if ( mw.viewport.isElementCloseToViewport( readMore, scrollThreshold ) ) {
$.when(
// Note we load dependencies here rather than ResourceLoader