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

Changed: Remove redundant parseInt() for table attributes.

Maciej Gołaszewski 7 лет назад
Родитель
Сommit
b251c59fd0

+ 1 - 1
packages/ckeditor5-table/src/commands/mergecellcommand.js

@@ -147,7 +147,7 @@ function getVerticalCell( tableCell, direction ) {
 		return;
 	}
 
-	const headingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );
+	const headingRows = table.getAttribute( 'headingRows' ) || 0;
 
 	// Don't search for mergeable cell if direction points out of the current table section.
 	if ( headingRows && ( ( direction == 'down' && rowIndex === headingRows - 1 ) || ( direction == 'up' && rowIndex === headingRows ) ) ) {

+ 1 - 1
packages/ckeditor5-table/src/commands/removecolumncommand.js

@@ -45,7 +45,7 @@ export default class RemoveColumnCommand extends Command {
 		const tableRow = tableCell.parent;
 		const table = tableRow.parent;
 
-		const headingColumns = parseInt( table.getAttribute( 'headingColumns' ) || 0 );
+		const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
 		const row = table.getChildIndex( tableRow );
 
 		// Cache the table before removing or updating colspans.

+ 1 - 1
packages/ckeditor5-table/src/commands/removerowcommand.js

@@ -45,7 +45,7 @@ export default class RemoveRowCommand extends Command {
 		const table = tableRow.parent;
 
 		const currentRow = table.getChildIndex( tableRow );
-		const headingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );
+		const headingRows = table.getAttribute( 'headingRows' ) || 0;
 
 		model.change( writer => {
 			if ( headingRows && currentRow <= headingRows ) {

+ 2 - 2
packages/ckeditor5-table/src/commands/settableheaderscommand.js

@@ -45,7 +45,7 @@ export default class SetTableHeadersCommand extends Command {
 		const table = getParentTable( selection.getFirstPosition() );
 
 		model.change( writer => {
-			const currentHeadingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );
+			const currentHeadingRows = table.getAttribute( 'headingRows' ) || 0;
 
 			if ( currentHeadingRows !== rowsToSet && rowsToSet > 0 ) {
 				// Changing heading rows requires to check if any of a heading cell is overlaping vertically the table head.
@@ -88,7 +88,7 @@ function getOverlappingCells( table, headingRowsToSet, currentHeadingRows ) {
 
 // @private
 function updateTableAttribute( table, attributeName, newValue, writer ) {
-	const currentValue = parseInt( table.getAttribute( attributeName ) || 0 );
+	const currentValue = table.getAttribute( attributeName ) || 0;
 
 	if ( newValue !== currentValue ) {
 		updateNumericAttribute( attributeName, newValue, table, writer, 0 );

+ 10 - 10
packages/ckeditor5-table/src/converters/downcast.js

@@ -46,8 +46,8 @@ export function downcastInsertTable( options = {} ) {
 		const tableWalker = new TableWalker( table );
 
 		const tableAttributes = {
-			headingRows: parseInt( table.getAttribute( 'headingRows' ) || 0 ),
-			headingColumns: parseInt( table.getAttribute( 'headingColumns' ) || 0 )
+			headingRows: table.getAttribute( 'headingRows' ) || 0,
+			headingColumns: table.getAttribute( 'headingColumns' ) || 0
 		};
 
 		for ( const tableWalkerValue of tableWalker ) {
@@ -98,8 +98,8 @@ export function downcastInsertRow( options = {} ) {
 		const tableWalker = new TableWalker( table, { startRow: row, endRow: row } );
 
 		const tableAttributes = {
-			headingRows: parseInt( table.getAttribute( 'headingRows' ) || 0 ),
-			headingColumns: parseInt( table.getAttribute( 'headingColumns' ) || 0 )
+			headingRows: table.getAttribute( 'headingRows' ) || 0,
+			headingColumns: table.getAttribute( 'headingColumns' ) || 0
 		};
 
 		for ( const tableWalkerValue of tableWalker ) {
@@ -139,8 +139,8 @@ export function downcastInsertCell( options = {} ) {
 		const tableWalker = new TableWalker( table, { startRow: rowIndex, endRow: rowIndex } );
 
 		const tableAttributes = {
-			headingRows: parseInt( table.getAttribute( 'headingRows' ) || 0 ),
-			headingColumns: parseInt( table.getAttribute( 'headingColumns' ) || 0 )
+			headingRows: table.getAttribute( 'headingRows' ) || 0,
+			headingColumns: table.getAttribute( 'headingColumns' ) || 0
 		};
 
 		// We need to iterate over a table in order to get proper row & column values from a walker
@@ -215,8 +215,8 @@ export function downcastTableHeadingRowsChange( options = {} ) {
 			const tableWalker = new TableWalker( table, { startRow: newRows ? newRows - 1 : newRows, endRow: oldRows - 1 } );
 
 			const tableAttributes = {
-				headingRows: parseInt( table.getAttribute( 'headingRows' ) || 0 ),
-				headingColumns: parseInt( table.getAttribute( 'headingColumns' ) || 0 )
+				headingRows: table.getAttribute( 'headingRows' ) || 0,
+				headingColumns: table.getAttribute( 'headingColumns' ) || 0
 			};
 
 			for ( const tableWalkerValue of tableWalker ) {
@@ -251,8 +251,8 @@ export function downcastTableHeadingColumnsChange( options = {} ) {
 		}
 
 		const tableAttributes = {
-			headingRows: parseInt( table.getAttribute( 'headingRows' ) || 0 ),
-			headingColumns: parseInt( table.getAttribute( 'headingColumns' ) || 0 )
+			headingRows: table.getAttribute( 'headingRows' ) || 0,
+			headingColumns: table.getAttribute( 'headingColumns' ) || 0
 		};
 
 		const oldColumns = data.attributeOldValue;

+ 2 - 2
packages/ckeditor5-table/src/tableutils.js

@@ -358,7 +358,7 @@ export default class TableUtils extends Plugin {
 
 				createCells( cellsToInsert, writer, Position.createAfter( tableCell ), newCellsAttributes );
 
-				const headingColumns = parseInt( table.getAttribute( 'headingColumns' ) || 0 );
+				const headingColumns = table.getAttribute( 'headingColumns' ) || 0;
 
 				// Update heading section if split cell is in heading section.
 				if ( headingColumns > splitCellColumn ) {
@@ -510,7 +510,7 @@ export default class TableUtils extends Plugin {
 				createEmptyRows( writer, table, splitCellRow + 1, cellsToInsert, 1, newCellsAttributes );
 
 				// Update heading section if split cell is in heading section.
-				const headingRows = parseInt( table.getAttribute( 'headingRows' ) || 0 );
+				const headingRows = table.getAttribute( 'headingRows' ) || 0;
 
 				if ( headingRows > splitCellRow ) {
 					updateNumericAttribute( 'headingRows', headingRows + cellsToInsert, table, writer );