|
|
@@ -16,29 +16,13 @@ import global from './global';
|
|
|
* @returns {HTMLElement|null}
|
|
|
*/
|
|
|
export default function getPositionedAncestor( element ) {
|
|
|
- while ( element && element.tagName.toLowerCase() != 'html' ) {
|
|
|
- if ( global.window.getComputedStyle( element ).position != 'static' ) {
|
|
|
- return element;
|
|
|
- }
|
|
|
+ if ( !element || !element.parentNode ) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
- element = element.parentElement;
|
|
|
+ if ( element.offsetParent === global.document.body ) {
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ return element.offsetParent;
|
|
|
}
|
|
|
-
|
|
|
-// export default function getPositionedAncestor( element ) {
|
|
|
-// if ( !element || !element.parentNode ) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-
|
|
|
-// if ( element.style.position && element.style.position !== 'static' ) {
|
|
|
-// return element;
|
|
|
-// }
|
|
|
-
|
|
|
-// if ( element.offsetParent === global.document.body ) {
|
|
|
-// return null;
|
|
|
-// }
|
|
|
-
|
|
|
-// return element.offsetParent;
|
|
|
-// }
|