Commit c9ff94e2 authored by baiyaaaaa's avatar baiyaaaaa Committed by Leopoldthecoder

fix popperjs get scrollParent bug (#1143)

parent fc41cf40
......@@ -1042,7 +1042,13 @@
* @returns {Element} offset parent
*/
function getScrollParent(element) {
if (element === root.document) {
var parent = element.parentNode;
if (!parent) {
return element;
}
if (parent === root.document) {
// Firefox puts the scrollTOp value on `documentElement` instead of `body`, we then check which of them is
// greater than 0 and return the proper element
if (root.document.body.scrollTop) {
......@@ -1054,16 +1060,16 @@
// Firefox want us to check `-x` and `-y` variations as well
if (
['scroll', 'auto'].indexOf(getStyleComputedProperty(element, 'overflow')) !== -1 ||
['scroll', 'auto'].indexOf(getStyleComputedProperty(element, 'overflow-x')) !== -1 ||
['scroll', 'auto'].indexOf(getStyleComputedProperty(element, 'overflow-y')) !== -1
['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow')) !== -1 ||
['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-x')) !== -1 ||
['scroll', 'auto'].indexOf(getStyleComputedProperty(parent, 'overflow-y')) !== -1
) {
// If the detected scrollParent is body, we perform an additional check on its parentNode
// in this way we'll get body if the browser is Chrome-ish, or documentElement otherwise
// fixes issue #65
return element === root.document.body ? getScrollParent(element.parentNode) : element;
return parent;
}
return element.parentNode ? getScrollParent(element.parentNode) : element;
return getScrollParent(element.parentNode);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment