Przeglądaj źródła

Used getBorderWidths() helper in getOptimalPosition().

Aleksander Nowodzinski 8 lat temu
rodzic
commit
d7a9daf8b9
1 zmienionych plików z 4 dodań i 3 usunięć
  1. 4 3
      packages/ckeditor5-utils/src/dom/position.js

+ 4 - 3
packages/ckeditor5-utils/src/dom/position.js

@@ -10,6 +10,7 @@
 import global from './global';
 import Rect from './rect';
 import getPositionedAncestor from './getpositionedancestor';
+import getBorderWidths from './getborderwidths';
 
 /**
  * Calculates the `position: absolute` coordinates of a given element so it can be positioned with respect to the
@@ -107,7 +108,7 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
 
 	if ( positionedElementAncestor ) {
 		const ancestorPosition = getAbsoluteRectCoordinates( new Rect( positionedElementAncestor ) );
-		const ancestorComputedStyles = global.window.getComputedStyle( positionedElementAncestor );
+		const ancestorBorderWidths = getBorderWidths( positionedElementAncestor );
 
 		// (https://github.com/ckeditor/ckeditor5-ui-default/issues/126)
 		// If there's some positioned ancestor of the panel, then its `Rect` must be taken into
@@ -129,8 +130,8 @@ export function getOptimalPosition( { element, target, positions, limiter, fitIn
 		// while `position: absolute` positioning does not consider it.
 		// E.g. `{ position: absolute, top: 0, left: 0 }` means upper left corner of the element,
 		// not upper-left corner of its border.
-		left -= parseInt( ancestorComputedStyles.borderLeftWidth, 10 );
-		top -= parseInt( ancestorComputedStyles.borderTopWidth, 10 );
+		left -= ancestorBorderWidths.left;
+		top -= ancestorBorderWidths.top;
 	}
 
 	return { left, top, name };