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

[BUGFIX] Restore mixin based EmberArray detection #20219

Closed

Conversation

jrjohnson
Copy link

@jrjohnson jrjohnson commented Oct 4, 2022

This is needed for ember-data to tap into and masquerade as an EmberArray to avoid being clobbered by Ember.A().

Refs emberjs/data#8202

This functionality was dropped in #20092 #20086

I couldn't figure out where a test for this would go, but opening a PR as a starting place for discussion and happy to update as needed.

@runspired
Copy link
Contributor

I'd be willing to add an ember-version dependent workaround if we don't want to restore the detect API, but there needs to be a mechanism for preventing what A can do to an object for EmberData to be able to help folks pave a path away from A.

@wagenet
Copy link
Member

wagenet commented Oct 4, 2022

@jrjohnson what part of #20092 changed this? The definitions of both Ember.A and isEmberArray were unchanged. The former was just moved.

@jrjohnson
Copy link
Author

@wagenet Sorry, I got lost in the git history with the move it was changed in #20086 in 8c6a159#diff-e5990a64605f374bfcd716f56aa0cd3c06573d6f48ebf05a245cfbf875a2c700L1805-L1809

@jrjohnson jrjohnson marked this pull request as ready for review October 4, 2022 14:55
@wagenet
Copy link
Member

wagenet commented Oct 4, 2022

@jrjohnson darn, my attempt to shift blame failed 😄

That said, I believe this is reasonable, I'll see if I can get someone else to second it.

Copy link
Contributor

@chriskrycho chriskrycho left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me, too. DIAF mixins and EmberArray… but until then yeah, let's do this to avoid breaking folks.

@jrjohnson
Copy link
Author

I'm not sure how to fix the test failures here, I think it maybe has to do with typescript and using the EmberArray import for the type and in code, but I don't know enough about typescript to fix this. I've tried various syntax and tried to figure out the difference between import type and import as well as looking around for other examples of something like this in the ember source, but I think I don't have enough of an idea on how typescript works to figure this out.

@wagenet
Copy link
Member

wagenet commented Oct 8, 2022

Annoyingly, I couldn't reproduce them locally either. I've been pretty busy as well 😕

@jrjohnson
Copy link
Author

I'm surprised this doesn't fail for you locally @wagenet, it certainly does for me. Maybe we can connect on discord and pair on debugging?

I think maybe this is a circular dependency issue. packages/@ember/-internals/utils/lib/ember-array.ts has import EmberArray from '@ember/array'; and packages/@ember/array/index.ts has import { isEmberArray, setEmberArray } from '@ember/-internals/utils'; and it's not immediately clear to me how to disconnect these.

@wagenet
Copy link
Member

wagenet commented Oct 11, 2022

@jrjohnson pairing would make sense. Are you on the Ember Discord? Maybe we can connect there.

This is needed for ember-data to tap into and masquerade as an
EmberArray to avoid being clobbered by Ember.A().
This allows ember data to both display a useful deprecation message when
a user runs Ember.A on a RecordArray and also to prevent it.
@jrjohnson jrjohnson force-pushed the ED8202-restore-data-a-detection branch from 8d02d3b to fdbed46 Compare October 18, 2022 05:15
@jrjohnson
Copy link
Author

@wagenet / @runspired I'm not sure if this is the right way to go, but wanted to put some strawman code up for discussion. Calls preventEmberA when it is present to prevent and object from being Ember.A()ed.

@wagenet
Copy link
Member

wagenet commented Oct 18, 2022

That's definitely one option. I think also, we want to change the behavior of Ember.A to not mutate anymore. The docs say that it doesn't (which we know is not true). I've talked with others on the core team about this. I'll try to look into it more this week.

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.

4 participants