Ver código fonte

Changed: Cache table attributes in TableWalker.

Maciej Gołaszewski 7 anos atrás
pai
commit
a5f6470722
1 arquivos alterados com 13 adições e 4 exclusões
  1. 13 4
      packages/ckeditor5-table/src/tablewalker.js

+ 13 - 4
packages/ckeditor5-table/src/tablewalker.js

@@ -116,6 +116,18 @@ export default class TableWalker {
 		 * @private
 		 */
 		this._cellSpans = new CellSpans();
+
+		/**
+		 * Cached table properties - returned for every yielded value.
+		 *
+		 * @readonly
+		 * @member {{headingRows: Number, headingColumns: Number}}
+		 * @private
+		 */
+		this._tableData = {
+			headingRows: this.table.getAttribute( 'headingRows' ) || 0,
+			headingColumns: this.table.getAttribute( 'headingColumns' ) || 0
+		};
 	}
 
 	/**
@@ -182,10 +194,7 @@ export default class TableWalker {
 				column: this.column,
 				rowspan: cell.getAttribute( 'rowspan' ) || 1,
 				colspan: cell.getAttribute( 'colspan' ) || 1,
-				table: {
-					headingRows: this.table.getAttribute( 'headingRows' ) || 0,
-					headingColumns: this.table.getAttribute( 'headingColumns' ) || 0
-				}
+				table: this._tableData
 			}
 		};
 	}