Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Temp fix for Glimmer 2 Backtracking re-render bug #438

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
7 changes: 4 additions & 3 deletions addon/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ const {
A: emberArray,
Object: EmberObject,
get,
set
set,
run
} = Ember;

export default EmberObject.extend({
unknownProperty(property) {
set(this, property, emberArray());
return get(this, property);
run.once(() => { set(this, property, emberArray()); });
Copy link
Contributor

Choose a reason for hiding this comment

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

this feels wrong. Adding a runloop entry shouldn't be necessary

Copy link
Author

Choose a reason for hiding this comment

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

In that case I'm unsure how to resolve this. At least as a temp solution moving the set into the runloop allows to avoid getting the hard error You modified errors.model twice in a single render from #438 and is also the often-mentioned solution from the original discussion of the Glimmer 2 issue.

Interestingly, the error is only thrown on validation of existing records.

If needed, I can try to reproduce this in a Twiddle.

Copy link
Contributor

Choose a reason for hiding this comment

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

@sevab We try with #445,What do you think?

return emberArray();
}
});
3 changes: 1 addition & 2 deletions addon/mixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Ember from 'ember';
import Errors from 'ember-validations/errors';
import Base from 'ember-validations/validators/base';
import getOwner from 'ember-getowner-polyfill';

const {
A: emberArray,
Expand Down Expand Up @@ -42,7 +41,7 @@ const pushValidatableObject = function(model, property) {
};

const lookupValidator = function(validatorName) {
let owner = getOwner(this);
let owner = Ember.getOwner(this);
let service = owner.lookup('service:validations');
let validators = [];
let cache;
Expand Down