jenkins-bot has submitted this change and it was merged.

Change subject: Element.getClosestScrollableContainer: Use 'body' or 
'documentElement' based on browser
......................................................................


Element.getClosestScrollableContainer: Use 'body' or 'documentElement' based on 
browser

Workaround for https://code.google.com/p/chromium/issues/detail?id=303131

Bug: T73609
Change-Id: I4ca3cb75090a68ddcd0baf345675c5011eb7444d
---
M src/Element.js
1 file changed, 33 insertions(+), 1 deletion(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, but someone else must approve
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/Element.js b/src/Element.js
index d92ce31..fe23221 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -287,6 +287,38 @@
 };
 
 /**
+ * Get scrollable object parent
+ *
+ * documentElement can't be used to get or set the scrollTop
+ * property on Blink. Changing and testing its value lets us
+ * use 'body' or 'documentElement' based on what is working.
+ *
+ * https://code.google.com/p/chromium/issues/detail?id=303131
+ *
+ * @static
+ * @param {HTMLElement} el Element to find scrollable parent for
+ * @return {HTMLElement} Scrollable parent
+ */
+OO.ui.Element.static.getRootScrollableElement = function ( el ) {
+       var scrollTop, body;
+
+       if ( OO.ui.scrollableElement === undefined ) {
+               body = el.ownerDocument.body;
+               scrollTop = body.scrollTop;
+               body.scrollTop = 1;
+
+               if ( body.scrollTop === 1 ) {
+                       body.scrollTop = scrollTop;
+                       OO.ui.scrollableElement = 'body';
+               } else {
+                       OO.ui.scrollableElement = 'documentElement';
+               }
+       }
+
+       return el.ownerDocument[ OO.ui.scrollableElement ];
+};
+
+/**
  * Get closest scrollable container.
  *
  * Traverses up until either a scrollable element or the root is reached, in 
which case the window
@@ -307,7 +339,7 @@
        }
 
        while ( $parent.length ) {
-               if ( $parent[0] === el.ownerDocument.body ) {
+               if ( $parent[0] === this.getRootScrollableElement( el ) ) {
                        return $parent[0];
                }
                i = props.length;

-- 
To view, visit https://gerrit.wikimedia.org/r/176666
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4ca3cb75090a68ddcd0baf345675c5011eb7444d
Gerrit-PatchSet: 6
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Prtksxna <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: Prtksxna <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to