@@ -93,23 +93,15 @@ export namespace position {
9393 }
9494
9595 export function getAbsoluteOffset ( target : HTMLElement ) : Offset {
96- let positionedElement ;
9796 let currentNode = target ;
9897 let margins = {
9998 top : 0 ,
10099 left : 0
101100 } ;
102101
103- // searches either for a parent `positionedElement` or for
104- // containing elements with additional margins
105- // once we have a `positionedElement` we can stop searching
106- // since we use offsetParent we end up skipping most elements
107- while ( currentNode . offsetParent && ! positionedElement ) {
102+ // searches for containing elements with additional margins
103+ while ( currentNode . offsetParent ) {
108104 const computed = getComputedStyle ( currentNode . offsetParent ) ;
109- if ( computed . position !== "static" ) {
110- positionedElement = currentNode . offsetParent ;
111- }
112-
113105 // find static elements with additional margins
114106 // since they tend to throw off our positioning
115107 // (usually this is just the body)
@@ -129,14 +121,8 @@ export namespace position {
129121 currentNode = currentNode . offsetParent as HTMLElement ;
130122 }
131123
132- // if we don't find any `relativeElement` on our walk
133- // default to the body
134- if ( ! positionedElement ) {
135- positionedElement = document . body ;
136- }
137-
138124 const targetRect = target . getBoundingClientRect ( ) ;
139- const relativeRect = positionedElement . getBoundingClientRect ( ) ;
125+ const relativeRect = document . body . getBoundingClientRect ( ) ;
140126 return {
141127 top : targetRect . top - relativeRect . top + margins . top ,
142128 left : targetRect . left - relativeRect . left + margins . left
0 commit comments