From c3c000014355a4565d35b10c4050f52e9beb5209 Mon Sep 17 00:00:00 2001 From: Christopher Garrett Date: Tue, 24 Apr 2018 11:36:12 -0700 Subject: [PATCH] [restructure] Simplify and flatten caching This is some of the precursor work to the new API: 1. Simplify the cell cache in general 2. Wrap columns and rows in proxies that add `meta` properties 3. Yield `value cell column row` as described in the new API 4. Have CollapseTree return the list of parents, which allows us to correctly figure out selection state in tree tables (more work and tests on that coming in future PRs) 5. Create a "row wrapper" component. This is necessary for wrapping the rows in proxy objects, since it should be done _after_ VC has done its work in order to remain stable, but before we yield to the `tr` because we don't want to complicate the `tr` logic (its been a struggling point on the refactor branch) --- addon/-private/collapse-tree.js | 27 ++-- addon/-private/meta-cache.js | 16 +++ addon/.gitkeep | 0 addon/components/-private/row-wrapper.js | 105 ++++++++++++++++ addon/components/ember-table-base-cell.js | 4 + addon/components/ember-table-cell.js | 6 +- addon/components/ember-table-row.js | 74 ++--------- addon/components/ember-table.js | 34 +++-- .../templates/components/ember-table-row.hbs | 13 +- addon/templates/components/ember-table.hbs | 19 ++- addon/utils/cell-proxy.js | 116 ++++++++---------- app/.gitkeep | 0 .../-ember-table-private/row-wrapper.js | 1 + package.json | 2 +- .../components/tree-table-grouping-cell.js | 10 +- tests/dummy/app/controllers/demo.js | 4 +- .../components/tree-table-grouping-cell.hbs | 6 +- tests/dummy/app/templates/demo.hbs | 10 +- tests/dummy/app/templates/simple.hbs | 4 +- tests/helpers/generate-table.js | 4 +- tests/integration/components/row-test.js | 6 - tests/unit/-private/collapse-tree-test.js | 18 +-- 22 files changed, 270 insertions(+), 209 deletions(-) create mode 100644 addon/-private/meta-cache.js delete mode 100644 addon/.gitkeep create mode 100644 addon/components/-private/row-wrapper.js delete mode 100644 app/.gitkeep create mode 100644 app/components/-ember-table-private/row-wrapper.js diff --git a/addon/-private/collapse-tree.js b/addon/-private/collapse-tree.js index 022c92c96..4e1a3df1a 100644 --- a/addon/-private/collapse-tree.js +++ b/addon/-private/collapse-tree.js @@ -232,10 +232,10 @@ class Node { every `objectAt` call. @param {number} index - the index to find - @param {number} depth - the depth of the current node in iteration - @return {{ value: object, depth: number }} + @param {Array} parents - the parents of the current node in the traversal + @return {{ value: object, parents: Array }} */ - objectAt(index, depth) { + objectAt(index, parents) { assert( 'index must be gte than 0 and less than the length of the node', index >= 0 && index < get(this, 'length') @@ -245,17 +245,17 @@ class Node { if (index === 0) { let value = get(this, 'value'); - return { value, depth, toggleCollapse: this.toggleCollapse }; + return { value, parents, isCollapsed: get(this, 'collapsed'), toggleCollapse: this.toggleCollapse }; } // Passed this node, remove it from the index and go one level deeper index = index - 1; - depth = depth + 1; + parents.push(this); if (get(this, 'isLeaf')) { let value = objectAt(get(this, 'value.children'), index); - return { value, depth }; + return { value, parents, isCollapsed: false }; } let children = get(this, 'children'); @@ -267,10 +267,10 @@ class Node { let child = children[offsetIndex]; if (Array.isArray(child)) { - return { value: child[index], depth }; + return { value: child[index], parents }; } - return child.objectAt(index, depth); + return child.objectAt(index, parents); } toggleCollapse = () => { @@ -361,7 +361,7 @@ export default class CollapseTree { /** @param {number} index - the index to find - @return {{ value: object, depth: number }} + @return {{ value: object, parents: Array }} */ objectAt(index) { if (index >= get(this, 'length') || index < 0) { @@ -369,11 +369,14 @@ export default class CollapseTree { } if (this.rootIsArray) { // If the root was an array, we added a "fake" top level node. Skip this node - // by adding one to the index, and "subtracting" one from the depth. - return this.root.objectAt(index + 1, -1); + // by adding one to the index, and shifting the first parent off the parent list. + let result = this.root.objectAt(index + 1, []); + result.parents.shift(); + + return result; } - return this.root.objectAt(index, 0); + return this.root.objectAt(index, []); } /** diff --git a/addon/-private/meta-cache.js b/addon/-private/meta-cache.js new file mode 100644 index 000000000..8bb3ac064 --- /dev/null +++ b/addon/-private/meta-cache.js @@ -0,0 +1,16 @@ +import ObjectProxy from '@ember/object/proxy'; +import EmberObject from '@ember/object'; + +const META_CACHE_MAP = new WeakMap(); + +export function metaCacheFor(obj, Class) { + if (META_CACHE_MAP.has(obj) === false) { + META_CACHE_MAP.set(obj, Class.create ? Class.create() : new Class()); + } + + return META_CACHE_MAP.get(obj); +} + +export default class MetaProxy extends ObjectProxy { + meta = metaCacheFor(this.content, EmberObject); +} diff --git a/addon/.gitkeep b/addon/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/addon/components/-private/row-wrapper.js b/addon/components/-private/row-wrapper.js new file mode 100644 index 000000000..77aef868c --- /dev/null +++ b/addon/components/-private/row-wrapper.js @@ -0,0 +1,105 @@ +import Component from '@ember/component'; +import hbs from 'htmlbars-inline-precompile'; + +import EmberObject, { get, set } from '@ember/object'; +import { A as emberA } from '@ember/array'; +import ObjectProxy from '@ember/object/proxy'; + +import { tagName } from '@ember-decorators/component'; +import { argument } from '@ember-decorators/argument'; + +import { computed } from '@ember-decorators/object'; +import { readOnly } from '@ember-decorators/object/computed'; + +import { metaCacheFor } from '../../-private/meta-cache'; +import CellProxy from '../../utils/cell-proxy'; + +class TableRowMeta extends EmberObject { + @readOnly('_parents.length') depth; + + @computed('_value', '_selectedRows.[]', '_parents.[]') + get isSelected() { + let selectedRows = get(this, '_selectedRows'); + return selectedRows.includes(this.get('_value')) || this.get('_parents').some((row) => selectedRows.includes(row)); + } +} + +class TableRowProxy extends ObjectProxy { + @computed('content') + get meta() { + return metaCacheFor(this.get('content'), TableRowMeta); + } +} + +@tagName('') +export default class RowWrapper extends Component { + layout = hbs` + {{yield proxy cells}} + `; + + @argument row; + + @argument rowIndex; + + @argument selectedRows; + + @argument columns; + + _cells = emberA(); + _proxy = TableRowProxy.create(); + + @computed('row', 'selectedRows.[]') + get proxy() { + let proxy = this._proxy; + + let { value: rowValue, parents, isCollapsed } = this.get('row'); + let rowIndex = this.get('rowIndex'); + + proxy.set('content', rowValue); + + let meta = proxy.get('meta'); + + set(meta, '_selectedRows', this.get('selectedRows')); + set(meta, '_value', rowValue); + set(meta, '_parents', parents); + + set(meta, 'index', rowIndex); + set(meta, 'isCollapsed', isCollapsed); + + return proxy; + } + + @computed('row.value', 'columns.[]') + get cells() { + let row = this.get('proxy'); + let columns = this.get('columns'); + let numColumns = get(columns, 'length'); + + let { _cells } = this; + + if (numColumns !== _cells.length) { + while (_cells.length < numColumns) { + _cells.push(CellProxy.create()); + } + + while (_cells.length > numColumns) { + _cells.pop(); + } + } + + return columns.map((column, i) => { + let valuePath = get(column, 'valuePath'); + + let cell = _cells[i]; + set(cell, 'row', row); + set(cell, 'valuePath', valuePath); + + return { + value: get(row, valuePath), + cellValue: cell, + columnValue: column, + rowValue: row + }; + }); + } +} diff --git a/addon/components/ember-table-base-cell.js b/addon/components/ember-table-base-cell.js index 68ffdd388..694cbce01 100644 --- a/addon/components/ember-table-base-cell.js +++ b/addon/components/ember-table-base-cell.js @@ -17,6 +17,10 @@ export default class EmberTableCell extends Component { @type(optional('number')) rowIndex; + @argument + @type(optional('object')) + api; + @argument @type('object') column; diff --git a/addon/components/ember-table-cell.js b/addon/components/ember-table-cell.js index 2f6bac051..d3148bc07 100644 --- a/addon/components/ember-table-cell.js +++ b/addon/components/ember-table-cell.js @@ -28,9 +28,9 @@ export default class EmberTableCell extends EmberTableBaseCell { onChecked; click() { - let rowValue = this.get('cell.row.value'); - let rowIndex = this.get('cell.row.index'); - let api = this.get('cell.row.api'); + let rowValue = this.get('rowValue'); + let rowIndex = this.get('rowIndex'); + let api = this.get('api'); if (this.get('columnIndex') === 0 && Array.isArray(get(rowValue, 'children'))) { api.toggleRowCollapse(rowIndex); diff --git a/addon/components/ember-table-row.js b/addon/components/ember-table-row.js index da3d060f1..a998b72ee 100644 --- a/addon/components/ember-table-row.js +++ b/addon/components/ember-table-row.js @@ -1,16 +1,13 @@ -import { get, set } from '@ember/object'; import Component from '@ember/component'; -import { action, computed } from '@ember-decorators/object'; +import { action } from '@ember-decorators/object'; import { readOnly } from '@ember-decorators/object/computed'; -import { attribute, className, classNames, tagName } from '@ember-decorators/component'; +import { className, classNames, tagName } from '@ember-decorators/component'; import { argument } from '@ember-decorators/argument'; import { required } from '@ember-decorators/argument/validation'; import { type } from '@ember-decorators/argument/type'; import layout from '../templates/components/ember-table-row'; -import { A as emberA } from '@ember/array'; -import { isNone } from '@ember/utils'; @tagName('tr') @classNames('et-tr') @@ -22,77 +19,26 @@ export default class EmberTableRow extends Component { * rendered cell view. */ _outerCellComponent = 'ember-table-cell'; - _cells = null; @argument @required @type('object') row; - @readOnly('row.api') api; + @readOnly('row.rowValue') rowValue; + @readOnly('row.rowValue.meta.index') rowIndex; - @readOnly('row.value') rowValue; - @readOnly('row.index') rowIndex; + @className + @readOnly('row.rowValue.meta.isSelected') + isSelected; - @readOnly('api.columns') columns; - @readOnly('api.cellProxyClass') cellProxyClass; - @readOnly('api.cellCache') cellCache; + @readOnly('row.api') api; + + @readOnly('row.cells') cells; @readOnly('api.numFixedColumns') numFixedColumns; - @readOnly('api.selectedRows') selectedRows; constructor() { super(...arguments); - - this._cells = emberA(); - } - - @computed('columns.[]') - get cells() { - let CellProxyClass = this.get('cellProxyClass'); - - let _rowComponent = this; - let _cache = this.get('cellCache'); - let columns = this.get('columns'); - let numColumns = get(columns, 'length'); - - let { _cells } = this; - - if (numColumns !== _cells.length) { - while (_cells.length < numColumns) { - _cells.push(CellProxyClass.create({ _cache, _rowComponent })); - } - - while (_cells.length > numColumns) { - _cells.pop(); - } - } - - for (let i = 0; i < numColumns; i++) { - let cell = _cells[i]; - let column = columns.objectAt !== undefined ? columns.objectAt(i) : columns[i]; - - set(cell, 'column', column); - set(cell, 'columnIndex', i); - set(cell, 'row', this.get('row')); - } - - return _cells; - } - - @className - @computed('selectedRows.[]', 'rowValue') - get isSelected() { - return this.get('selectedRows').indexOf(this.get('rowValue')) >= 0; - } - - @attribute - @computed('row.api.staticRowHeight') - get style() { - let staticRowHeight = this.get('row.api.staticRowHeight'); - if (!isNone(staticRowHeight)) { - return `height: ${staticRowHeight}px;`; - } - return ''; } click(event) { diff --git a/addon/components/ember-table.js b/addon/components/ember-table.js index ce6a43422..91e181382 100644 --- a/addon/components/ember-table.js +++ b/addon/components/ember-table.js @@ -14,7 +14,6 @@ import layout from '../templates/components/ember-table'; import { htmlSafe } from '@ember/string'; import { run } from '@ember/runloop'; import Component from '@ember/component'; -import CellProxy from '../utils/cell-proxy'; import { move } from '../utils/array'; import { get, set } from '@ember/object'; import { isNone } from '@ember/utils'; @@ -26,6 +25,8 @@ import CollapseTree from '../-private/collapse-tree'; import { setupLegacyStickyPolyfill, teardownLegacyStickyPolyfill } from '../-private/sticky/legacy-sticky-polyfill'; import { setupTableStickyPolyfill, teardownTableStickyPolyfill } from '../-private/sticky/table-sticky-polyfill'; +import MetaProxy from '../-private/meta-cache'; + const HEAD_ALIGN_BAR_WIDTH = 5; const COLUMN_MODE_STANDARD = 'standard'; @@ -236,12 +237,6 @@ export default class EmberTable extends Component { constructor() { super(...arguments); - this.cellCache = new WeakMap(); - - // Create a unique CellProxy class for this table instance, that way transient data won't - // pollute the prototype of the main proxy class. - this.cellProxyClass = class extends CellProxy {}; - this.token = new Token(); } @@ -415,19 +410,26 @@ export default class EmberTable extends Component { */ @computed('hasSubcolumns', 'columns.@each.subcolumns') get bodyColumns() { - if (this.get('hasSubcolumns') !== true) { - return this.get('columns'); - } - let bodyColumns = emberA(); this.get('columns').forEach((column) => { let subcolumns = get(column, 'subcolumns'); if (isNone(subcolumns) || get(subcolumns, 'length') === 0) { - bodyColumns.pushObject(column); + let proxy = MetaProxy.create({ content: column }); + + proxy.set('meta.index', bodyColumns.length); + + bodyColumns.pushObject(proxy); } else { - subcolumns.forEach((subcolumn) => bodyColumns.pushObject(subcolumn)); + subcolumns.forEach((subcolumn) => { + let proxy = MetaProxy.create({ content: subcolumn }); + + proxy.set('meta.index', bodyColumns.length); + + bodyColumns.pushObject(proxy); + }); } }); + return bodyColumns; } @@ -488,7 +490,6 @@ export default class EmberTable extends Component { } @computed( - 'cellCache', 'cellProxyClass', 'numFixedColumns', 'targetObject', @@ -506,11 +507,8 @@ export default class EmberTable extends Component { return { rowHeight: this.get('rowHeight'), - cellCache: this.get('cellCache'), - cellProxyClass: this.get('cellProxyClass'), numFixedColumns: this.get('numFixedColumns'), targetObject: this, - columns: this.get('bodyColumns'), selectedRows: this.get('selectedRows'), staticRowHeight, @@ -706,7 +704,7 @@ export default class EmberTable extends Component { let oldIndex = columnIndex; if (this._currentColumnIndex !== columnIndex) { - move(this, 'bodyColumns', columnIndex, this._currentColumnIndex); + move(this, 'columns', columnIndex, this._currentColumnIndex); } this._currentColumnIndex = -1; diff --git a/addon/templates/components/ember-table-row.hbs b/addon/templates/components/ember-table-row.hbs index 105587b43..3bcf4f32d 100644 --- a/addon/templates/components/ember-table-row.hbs +++ b/addon/templates/components/ember-table-row.hbs @@ -1,14 +1,15 @@ {{#each cells as |cell columnIndex|}} {{#component _outerCellComponent - rowValue=rowValue - rowIndex=rowIndex - column=cell.column - columnIndex=columnIndex + rowValue=cell.rowValue + rowIndex=cell.rowValue.meta.index + column=cell.columnValue + columnIndex=cell.columnValue.meta.index + api=api numFixedColumns=numFixedColumns rowSelected=isSelected onChecked="toggleRowSelection" - cell=cell + cell=cell.cellValue }} - {{yield cell rowValue rowIndex}} + {{yield cell.value cell.cellValue cell.columnValue cell.rowValue}} {{/component}} {{/each}} diff --git a/addon/templates/components/ember-table.hbs b/addon/templates/components/ember-table.hbs index a076d4b22..f1ab56bcb 100644 --- a/addon/templates/components/ember-table.hbs +++ b/addon/templates/components/ember-table.hbs @@ -47,12 +47,19 @@ as |rowValue rowIndex| }} - {{yield (hash - value=rowValue.value - depth=rowValue.depth - index=rowIndex - api=api) - }} + {{#-ember-table-private/row-wrapper + row=rowValue + rowIndex=rowIndex + selectedRows=selectedRows + columns=bodyColumns + + as |wrappedRow cells|}} + {{yield (hash + rowValue=wrappedRow + cells=cells + api=api) + }} + {{/-ember-table-private/row-wrapper}} {{/vertical-collection}} diff --git a/addon/utils/cell-proxy.js b/addon/utils/cell-proxy.js index f83bc4109..40d7000ce 100644 --- a/addon/utils/cell-proxy.js +++ b/addon/utils/cell-proxy.js @@ -1,83 +1,65 @@ -import EmberObject, { - computed as emberComputed, - get, - set -} from '@ember/object'; +/* globals Ember */ +import EmberObject, { get } from '@ember/object'; +import { addObserver } from '@ember/object/observers'; -import { SUPPORTS_NEW_COMPUTED } from 'ember-compatibility-helpers'; - -import { computed } from '@ember-decorators/object'; -import { readOnly } from '@ember-decorators/object/computed'; +const CELL_CACHE = new WeakMap(); export default class CellProxy extends EmberObject { - column = null; - columnIndex = null; + constructor() { + super(); + + this._watchedProperties = []; - row = null; + this.row = null; + this.valuePath = null; - @readOnly('_rowComponent.rowValue') rowValue; - @readOnly('_rowComponent.rowIndex') rowIndex; + addObserver(this, 'row', this.notifyPropertyChanges); + addObserver(this, 'valuePath', this.notifyPropertyChanges); + } - @computed('rowValue', 'column.valuePath') - get value() { - let rowValue = get(this, 'rowValue'); - let valuePath = get(this, 'column.valuePath'); + notifyPropertyChanges = () => { + for (let property of this._watchedProperties) { + Ember.propertyDidChange(this, property); + } + }; - return get(rowValue, valuePath); + willWatchProperty(key) { + if (!(key in this)) { + this._watchedProperties.push(key); + } } - set value(value) { - let rowValue = get(this, 'rowValue'); - let valuePath = get(this, 'column.valuePath'); + didUnwatchProperty(key) { + let i = this._watchedProperties.indexOf(key); - set(rowValue, valuePath, value); + if (i !== -1) { + this._watchedProperties.splice(i, 1); + } } unknownProperty(key) { - let prototype = Object.getPrototypeOf(this); - - let setValueFunc = (context, k, value) => { - let cache = get(context, '_cache'); - let rowValue = get(context, 'rowValue'); - let valuePath = get(context, 'column.valuePath'); - - if (!cache.has(rowValue)) { - cache.set(rowValue, Object.create(null)); - } - - return cache.get(rowValue)[`${valuePath}:${k}`] = value; - }; - - let getValueFunc = (context, key) => { - let cache = get(context, '_cache'); - let rowValue = get(context, 'rowValue'); - let valuePath = get(context, 'column.valuePath'); - - if (cache.has(rowValue)) { - return cache.get(rowValue)[`${valuePath}:${key}`]; - } - - return undefined; - }; - - if (SUPPORTS_NEW_COMPUTED) { - prototype[key] = emberComputed('rowValue', 'column.valuePath', { - get(key) { - return getValueFunc(this, key); - }, - - set(key, value) { - return setValueFunc(this, key, value); - } - }); - } else { - prototype[key] = emberComputed('rowValue', 'column.valuePath', function(key, value) { - if (arguments.length > 1) { - return setValueFunc(this, key, value); - } - - return getValueFunc(this, key); - }); + let row = get(this, 'row.content'); + let valuePath = get(this, 'valuePath'); + + if (CELL_CACHE.has(row)) { + return CELL_CACHE.get(row)[`${valuePath}:${key}`]; } + + return undefined; + } + + setUnknownProperty(key, value) { + let row = get(this, 'row.content'); + let valuePath = get(this, 'valuePath'); + + if (!CELL_CACHE.has(row)) { + CELL_CACHE.set(row, Object.create(null)); + } + + CELL_CACHE.get(row)[`${valuePath}:${key}`] = value; + + Ember.propertyDidChange(this, key); + + return value; } } diff --git a/app/.gitkeep b/app/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/components/-ember-table-private/row-wrapper.js b/app/components/-ember-table-private/row-wrapper.js new file mode 100644 index 000000000..b6486da29 --- /dev/null +++ b/app/components/-ember-table-private/row-wrapper.js @@ -0,0 +1 @@ +export { default } from 'ember-table/components/-private/row-wrapper'; diff --git a/package.json b/package.json index 6196a8329..5b4eb9d21 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "ember-assign-polyfill": "^2.2.0", "ember-cli-babel": "^6.7.1", "ember-cli-htmlbars": "^2.0.1", + "ember-cli-htmlbars-inline-precompile": "^1.0.2", "ember-cli-node-assets": "^0.2.2", "ember-cli-sass": "^7.0.0", "ember-compatibility-helpers": "^0.1.2", @@ -47,7 +48,6 @@ "ember-cli-addon-docs": "ember-learn/ember-cli-addon-docs", "ember-cli-dependency-checker": "^2.0.0", "ember-cli-eslint": "^4.0.0", - "ember-cli-htmlbars-inline-precompile": "^1.0.2", "ember-cli-inject-live-reload": "^1.4.1", "ember-cli-qunit": "^4.0.0", "ember-cli-shims": "^1.1.0", diff --git a/tests/dummy/app/components/tree-table-grouping-cell.js b/tests/dummy/app/components/tree-table-grouping-cell.js index cfbdba59d..3c2bdcda7 100644 --- a/tests/dummy/app/components/tree-table-grouping-cell.js +++ b/tests/dummy/app/components/tree-table-grouping-cell.js @@ -10,14 +10,18 @@ import layout from '../templates/components/tree-table-grouping-cell'; export default class TreeTableGroupingCell extends Component { layout = layout; + @argument + @type(optional('any')) + value; + @argument @type(optional('object')) - cell; + row; @attribute - @computed('cell.row.depth') + @computed('row.depth') get style() { - let depth = this.get('cell.row.depth'); + let depth = this.get('row.depth'); return htmlSafe(`padding-left: ${depth * 20}px;`); } } diff --git a/tests/dummy/app/controllers/demo.js b/tests/dummy/app/controllers/demo.js index e74e2d87d..48e8f18b7 100644 --- a/tests/dummy/app/controllers/demo.js +++ b/tests/dummy/app/controllers/demo.js @@ -80,8 +80,8 @@ export default Controller.extend({ }), actions: { - onCellClicked(cell) { - if (cell.get('columnIndex') !== 0) { + onCellClicked(cell, columnIndex) { + if (columnIndex !== 0) { cell.set('wasClicked', true); } } diff --git a/tests/dummy/app/templates/components/tree-table-grouping-cell.hbs b/tests/dummy/app/templates/components/tree-table-grouping-cell.hbs index 987ae350f..787258f9d 100644 --- a/tests/dummy/app/templates/components/tree-table-grouping-cell.hbs +++ b/tests/dummy/app/templates/components/tree-table-grouping-cell.hbs @@ -1,4 +1,4 @@ -{{#if cell.row.value.children}} - {{if cell.row.value.collapsed "+" "-"}} +{{#if row.children}} + {{if row.collapsed "+" "-"}} {{/if}} -{{cell.value}} +{{value}} diff --git a/tests/dummy/app/templates/demo.hbs b/tests/dummy/app/templates/demo.hbs index 252a98608..a64db6c5c 100644 --- a/tests/dummy/app/templates/demo.hbs +++ b/tests/dummy/app/templates/demo.hbs @@ -10,14 +10,14 @@ {{#ember-table-row row=t - as |cell| + as |value cell column row| }} - {{#if cell.column.cellComponent}} - {{component cell.column.cellComponent cell=cell}} + {{#if column.cellComponent}} + {{component column.cellComponent value=value row=row}} {{else}} -
- {{cell.value}} +
+ {{value}}
{{/if}} {{/ember-table-row}} diff --git a/tests/dummy/app/templates/simple.hbs b/tests/dummy/app/templates/simple.hbs index 37d30fe51..a00d7a217 100644 --- a/tests/dummy/app/templates/simple.hbs +++ b/tests/dummy/app/templates/simple.hbs @@ -9,9 +9,9 @@ }} {{#ember-table-row row=t - as |cell| + as |value| }} - {{cell.value}} + {{value}} {{/ember-table-row}} {{/ember-table}}
diff --git a/tests/helpers/generate-table.js b/tests/helpers/generate-table.js index 0bed22815..abb45c9b4 100644 --- a/tests/helpers/generate-table.js +++ b/tests/helpers/generate-table.js @@ -31,9 +31,9 @@ const fullTable = hbs` {{#component rowComponent row=row - as |cell| + as |value| }} - {{cell.value}} + {{value}} {{/component}} {{/ember-table}} diff --git a/tests/integration/components/row-test.js b/tests/integration/components/row-test.js index fc596d8fc..d9d7b9543 100644 --- a/tests/integration/components/row-test.js +++ b/tests/integration/components/row-test.js @@ -25,11 +25,5 @@ module('Integration | row', function() { assert.ok(table.rows.eq(0).isCustomRow, 'Table has custom row'); }); - - test('can set a custom row height', async function(assert) { - await generateTable(this, { staticHeight: true, estimateRowHeight: 100 }); - - assert.equal(table.rows.eq(0).height, 100, 'Row height is set to custom height.'); - }); }); }); diff --git a/tests/unit/-private/collapse-tree-test.js b/tests/unit/-private/collapse-tree-test.js index 2796e17eb..30a30f48b 100644 --- a/tests/unit/-private/collapse-tree-test.js +++ b/tests/unit/-private/collapse-tree-test.js @@ -50,7 +50,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 7; i++) { assert.equal(tree.objectAt(i).value.value, i); - assert.equal(tree.objectAt(i).depth, expectedDepth[i]); + assert.equal(tree.objectAt(i).parents.length, expectedDepth[i]); } assert.equal(tree.objectAt(length + 1), undefined); @@ -66,7 +66,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 10; i++) { assert.equal(tree.objectAt(i).value.value, i); - assert.equal(tree.objectAt(i).depth, expectedDepth[i]); + assert.equal(tree.objectAt(i).parents.length, expectedDepth[i]); } }); @@ -79,7 +79,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 9; i++) { assert.equal(tree.objectAt(i).value.value, i); - assert.equal(tree.objectAt(i).depth, expectedDepth[i]); + assert.equal(tree.objectAt(i).parents.length, expectedDepth[i]); } }); @@ -96,7 +96,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 5; i++) { assert.equal(collapseTree.objectAt(i).value.value, expectedValue[i]); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } set(tree.children[0], 'collapsed', false); @@ -108,7 +108,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 5; i++) { assert.equal(collapseTree.objectAt(i).value.value, expectedValue[i]); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } }); @@ -128,7 +128,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 5; i++) { assert.equal(collapseTree.objectAt(i).value.value, expectedValue[i]); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } collapseTree.objectAt(1).toggleCollapse(); @@ -142,7 +142,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 5; i++) { assert.equal(collapseTree.objectAt(i).value.value, expectedValue[i]); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } }); @@ -160,7 +160,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 8; i++) { assert.equal(collapseTree.objectAt(i).value.value, i); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } }); @@ -178,7 +178,7 @@ module('Unit | Private | CollapseTree', function() { for (let i = 0; i < 7; i++) { assert.equal(collapseTree.objectAt(i).value.value, i); - assert.equal(collapseTree.objectAt(i).depth, expectedDepth[i]); + assert.equal(collapseTree.objectAt(i).parents.length, expectedDepth[i]); } }); });