Skip to content

Commit

Permalink
fix(classes/{Column,Row}): assign properties in the Ember init hook
Browse files Browse the repository at this point in the history
This sidesteps the implicit run loop creation in Ember 2.12

https://travis-ci.org/offirgolan/ember-light-table/jobs/344818839#L790
  • Loading branch information
buschtoens committed Feb 22, 2018
1 parent 9591097 commit 5905400
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions addon/classes/Column.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,16 @@ export default class Column extends EmberObject.extend({
let isHidden = this.get('isHidden');

return emberArray(isHidden ? [] : subColumns.filterBy('isHidden', false));
}).readOnly()
}).readOnly(),

init(...args) {
this._super(...args);

const subColumns = emberArray(makeArray(this.get('subColumns')).map((sc) => new Column(sc)));
subColumns.setEach('parent', this);

this.set('subColumns', subColumns);
}
}) {
/**
* @class Column
Expand All @@ -323,20 +332,14 @@ export default class Column extends EmberObject.extend({
constructor(options = {}) {
// TODO: Revert this, when babel#5862 is resolved.
// https://github.com/babel/babel/issues/5862
super();
// HACK: Passing properties to super instead of manually setting them fixes the
// implicit run loop creation for Ember 2.12.
// https://travis-ci.org/offirgolan/ember-light-table/jobs/344818839#L790
super(options);

if (options instanceof Column) {
return options;
}

this.setProperties(options);

let { subColumns } = options;

subColumns = emberArray(makeArray(subColumns).map((sc) => new Column(sc)));
subColumns.setEach('parent', this);

this.set('subColumns', subColumns);
}
}

Expand Down
8 changes: 4 additions & 4 deletions addon/classes/Row.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ export default class Row extends ObjectProxy.extend({
constructor(content, options = {}) {
// TODO: Revert this, when babel#5862 is resolved.
// https://github.com/babel/babel/issues/5862
super();
// HACK: Passing properties to super instead of manually setting them fixes the
// implicit run loop creation for Ember 2.12.
// https://travis-ci.org/offirgolan/ember-light-table/jobs/344818839#L790
super(Object.assign({}, options, { content }));

if (content instanceof Row) {
return content;
}

this.setProperties(options);
this.set('content', content);
}
}

Expand Down

0 comments on commit 5905400

Please sign in to comment.