Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: did-update entaglement on Ember 3.23+ #286

Merged
merged 1 commit into from
Dec 18, 2020
Merged

fix: did-update entaglement on Ember 3.23+ #286

merged 1 commit into from
Dec 18, 2020

Conversation

boris-petrov
Copy link
Contributor

@boris-petrov boris-petrov commented Nov 17, 2020

Copy link
Owner

@buschtoens buschtoens left a comment

Choose a reason for hiding this comment

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

Thanks for investigating and fixing this! ❤️

Comment on lines 24 to 34
if (!this.didRun) {
this.didRun = true;
positional.forEach(() => {});
Object.values(named).forEach(() => {});
return;
}
fn(positional.slice(1), named);
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if (!this.didRun) {
this.didRun = true;
positional.forEach(() => {});
Object.values(named).forEach(() => {});
return;
}
fn(positional.slice(1), named);
if (!this.didRun) {
this.didRun = true;
// Consume individual properties to entangle tracking.
// https://github.com/emberjs/ember.js/issues/19277
Object.values(positional);
Object.values(named);
return;
}
fn(positional.slice(1), named);

I think just calling Object.values(...) should be sufficient, as this already triggers the getters for each property.

Copy link
Owner

@buschtoens buschtoens Nov 17, 2020

Choose a reason for hiding this comment

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

Do we also need to access positional.length to support positional.pushObject('new tail')?

Copy link
Owner

Choose a reason for hiding this comment

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

Similarly, would this work when a new key is added to named via named.set('newKey', true)?

Copy link
Owner

@buschtoens buschtoens Nov 17, 2020

Choose a reason for hiding this comment

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

You don't need to verify these things, if you don't wanna. I'll check this out later today, add tests and migrate the CI setup to GitHub Actions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I force-pushed the suggested change. However, I'm not sure about the things you're asking. If you can check them later, that would be great, thanks!

Note that this is a "hack" around (I guess) the Ember bug. If they fix it soon, you could then revert that change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, Object.values doesn't work on an array:

Object.keys() was called on the positional arguments array for a helper, which is not supported. This function is a low-level function that should not need to be called for positional argument arrays. You may be attempting to iterate over the array using for...in instead of for...of.

Copy link
Owner

Choose a reason for hiding this comment

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

Object.values([1, 2, 3]) does work on an array. It's rather that the Ember args proxy apparently has a bug and doesn't support being used with Object.values(positional) 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@buschtoens - I'm not sure when the bug is going to be fixed on Ember's side - do you mind merging this and releasing a new version and later on you can revert it when Ember fixes it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{{did-update}} fails for Ember 3.23 beta
2 participants