8
0
Просмотр исходного кода

Docs fixes and code refactoring in the getBorderWidths utility.

Aleksander Nowodzinski 8 лет назад
Родитель
Сommit
8746541b0c
1 измененных файлов с 8 добавлено и 13 удалено
  1. 8 13
      packages/ckeditor5-utils/src/dom/getborderwidths.js

+ 8 - 13
packages/ckeditor5-utils/src/dom/getborderwidths.js

@@ -10,24 +10,19 @@
 import global from './global';
 
 /**
- * Returns an object containing CSS border withs of a specified `HTMLElement`.
+ * Returns an object containing CSS border widths of a specified HTML element.
  *
  * @param {HTMLElement} element An element which has CSS borders.
  * @param {Object} An object containing `top`, `left`, `right` and `bottom` properties
  * with numerical values of the `border-[top,left,right,bottom]-width` CSS styles.
  */
 export default function getBorderWidths( element ) {
-	const computedStyles = global.window.getComputedStyle( element );
-	const borderWidths = {
-		top: computedStyles.borderTopWidth,
-		right: computedStyles.borderRightWidth,
-		bottom: computedStyles.borderBottomWidth,
-		left: computedStyles.borderLeftWidth
-	};
-
-	for ( const width in borderWidths ) {
-		borderWidths[ width ] = parseInt( borderWidths[ width ], 10 );
-	}
+	const style = global.window.getComputedStyle( element );
 
-	return borderWidths;
+	return {
+		top: parseInt( style.borderTopWidth, 10 ),
+		right: parseInt( style.borderRightWidth, 10 ),
+		bottom: parseInt( style.borderBottomWidth, 10 ),
+		left: parseInt( style.borderLeftWidth, 10 )
+	};
 }