Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ before_install:
- export PATH=$HOME/.yarn/bin:$PATH

install:
- yarn install --no-lockfile --non-interactive
- yarn install --no-lockfile --non-interactive --ignore-engines

script:
# Usually, it's ok to finish the test scenario without reverting
Expand Down
12 changes: 10 additions & 2 deletions addon/components/ember-tbody/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Component from '@ember/component';

import { run } from '@ember/runloop';
import { computed } from '@ember/object';
import { observer } from '../../-private/utils/observer';
import { bool, readOnly, or } from '@ember/object/computed';
Expand Down Expand Up @@ -234,7 +235,9 @@ export default Component.extend({
*/
canSelect: bool('onSelect'),

'data-test-row-count': readOnly('wrappedRows.length'),
dataTestRowCount: null,

'data-test-row-count': readOnly('dataTestRowCount'),

init() {
this._super(...arguments);
Expand Down Expand Up @@ -297,7 +300,7 @@ export default Component.extend({

/**
Computed property which updates the CollapseTree and erases caches. This is
a computed for 1.11 compatibility, otherwise it would make sense to use
a computed for 1.12 compatibility, otherwise it would make sense to use
lifecycle hooks instead.
*/
wrappedRows: computed('rows', function() {
Expand All @@ -306,6 +309,11 @@ export default Component.extend({
this.collapseTree.set('rowMetaCache', this.rowMetaCache);
this.collapseTree.set('rows', rows);

run.schedule('actions', () => {
// eslint-disable-next-line ember-best-practices/no-side-effect-cp
this.set('dataTestRowCount', this.get('wrappedRows.length')); // eslint-disable-line ember/no-side-effects
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need two eslint-disable comments here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are indeed two rules which error on this.

It is actually a bit annoying since the side effects really begin on line 309, but I presume the lint only catches on this.set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this passes the test then LGTM but obviously this super sucks explicitly adding this sideeffectyness. Thankfully it's pretty limited side effect but still 🤢

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, as noted this is expanding on an already-existing side effect which caused the problem. An alternative here would be to simply stop offering the data-tests-row-count attribute. If we drop 1.12 then this would be rewritten using didReceiveAttrs and the count could be set there without any CP side effects.

});

return this.collapseTree;
}),

Expand Down