Bartosz Dziewoński has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/343549 )
Change subject: Element: Add special case for document root in getClosestScrollableContainer ...................................................................... Element: Add special case for document root in getClosestScrollableContainer Also documentation improvements. Bug: T160852 Change-Id: Ifceac7e11ba0db2635f55d554f266fb13dc71807 --- M src/Element.js 1 file changed, 12 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/49/343549/1 diff --git a/src/Element.js b/src/Element.js index 3b9085d..9398a67 100644 --- a/src/Element.js +++ b/src/Element.js @@ -584,7 +584,7 @@ }() ); /** - * Get scrollable object parent + * Get the root scrollable element of given element's document. * * documentElement can't be used to get or set the scrollTop * property on Blink. Changing and testing its value lets us @@ -593,8 +593,9 @@ * https://code.google.com/p/chromium/issues/detail?id=303131 * * @static - * @param {HTMLElement} el Element to find scrollable parent for - * @return {HTMLElement} Scrollable parent + * @param {HTMLElement} el Element to find root scrollable parent for + * @return {HTMLElement} Scrollable parent, `document.body` or `document.documentElement` + * depending on browser */ OO.ui.Element.static.getRootScrollableElement = function ( el ) { var scrollTop, body; @@ -618,8 +619,8 @@ /** * Get closest scrollable container. * - * Traverses up until either a scrollable element or the root is reached, in which case the window - * will be returned. + * Traverses up until either a scrollable element or the root is reached, in which case the root + * scrollable element will be returned (see #getRootScrollableElement). * * @static * @param {HTMLElement} el Element to find scrollable container for @@ -637,6 +638,12 @@ props = [ 'overflow-' + dimension ]; } + // Special case for the document root (which doesn't really have any scrollable container, since + // it is the ultimate scrollable container, but this is probably saner than null or exception) + if ( $( el ).is( 'html, body' ) ) { + return this.getRootScrollableElement( el ); + } + while ( $parent.length ) { if ( $parent[ 0 ] === this.getRootScrollableElement( el ) ) { return $parent[ 0 ]; -- To view, visit https://gerrit.wikimedia.org/r/343549 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifceac7e11ba0db2635f55d554f266fb13dc71807 Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Bartosz Dziewoński <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
