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

use .slice when .toArray is not present #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

artemgurzhii
Copy link

No description provided.

Copy link

netlify bot commented Sep 9, 2024

Deploy Preview for ember-drag-drop ready!

Name Link
🔨 Latest commit ad1c4de
🔍 Latest deploy log https://app.netlify.com/sites/ember-drag-drop/deploys/66def68bc6b2c10008892c41
😎 Deploy Preview https://deploy-preview-10--ember-drag-drop.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bvedad
Copy link

bvedad commented Jan 8, 2025

Any progress on this one? I am encountering this issue as I wanted to perform Ember upgrade.

@SergeAstapov SergeAstapov added the bug Something isn't working label Jan 8, 2025
@SergeAstapov
Copy link

@artemgurzhii thank you! Do you think you could add a test case to ensure this is working as expected now and in the future?

@artemgurzhii
Copy link
Author

@SergeAstapov sure, I can try to. do you have ideas on how you would expect it to be tested?

@artemgurzhii
Copy link
Author

@bvedad I have added

<script>
  // TODO: remove once https://github.com/adopted-ember-addons/ember-drag-drop/pull/10 is merged & released
  Array.prototype.toArray = function() {
    return this.slice();
  };
</script>

to app/index.html and tests/index.html files for now.

Or you can also try to install a forked version, ie replace "ember-drag-drop": "^1.0.0", with "ember-drag-drop": "uplisting/ember-drag-drop#main", until a new version is released. I have used first option, so that I don't miss if any new version of ember-drag-drop is released

@SergeAstapov
Copy link

@SergeAstapov sure, I can try to. do you have ideas on how you would expect it to be tested?

as far as I can see, it's a problem with @sortableObjectList argument which could be native Array or could be an EmberArray.

as far as I can see, this PR makes it possible to pass to @sortableObjectList argument native Array which does not have .toArray() method.

We have tests in https://github.com/adopted-ember-addons/ember-drag-drop/blob/main/test-app/tests/integration/components/sortable-objects-test.js#L10 that all verify it works with pojoData array which is EmberArray.

Hence, could you please add a test case in https://github.com/adopted-ember-addons/ember-drag-drop/blob/main/test-app/tests/integration/components/sortable-objects-test.js#L10 to test <SortableObjects> component rendering with @sortableObjectList argument like

let nativePojoData = [
  { id: 1, title: 'Number 1' },
  { id: 2, title: 'Number 2' },
  { id: 3, title: 'Number 3' },
  { id: 4, title: 'Number 4' },
];

@artemgurzhii
Copy link
Author

@SergeAstapov I'm not sure that it would work, as it requires environment config change like so:

EmberENV: {
  EXTEND_PROTOTYPES: false,
},

as if not - Ember would globally define their custom array methods on the global array prototype, which means that all arrays(Ember.A() and [] as well) will have access to those methods.

@SergeAstapov
Copy link

@artemgurzhii I would say this what we gonna do anyways to ensure support of newer versions of Ember.js where prototype extensions being deprecated and removed

@artemgurzhii
Copy link
Author

@SergeAstapov should we then disable prototype extensions to test that functionality explicitly?

@SergeAstapov
Copy link

@artemgurzhii yes, I believe so - that way we can explicitly pass both native Array and EmberArray as arguments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants