[FEATURE ember-runtime-enumerable-includes] Implements Array.includes and deprecates Array.contains#13553
Conversation
|
Oh awesome, thanks for getting this implementation done! |
|
Here is a first proposal for emberjs/rfcs#136. Work is in progress and feedbacks expected. I made the asumption that we have to keep Aliasing |
|
@bmeurant Thanks :-)
|
|
@mixonic thx for your feedback. I updated this PR to keep current implementation for
Does it means that I should also remove |
|
I believe that the deprecation should be included here when the feature flag is enabled. |
|
@mixonic I added feature flag and move deprecation behind it. Let me know if I forgotten something. I also removed But I was wondering: doing that, users will loose the information that |
|
@bmeurant Yeah the documentation may require some followup tweaks. Feature flagging things like the |
FEATURES.md
Outdated
There was a problem hiding this comment.
Again here I lean toward Enumerable#contains, per emberjs/website#2600 (comment). It is a Rubyish approach, curious if there are other thoughts.
There was a problem hiding this comment.
I think Enumerable#contains is the convention in Ember even though it was originally a rubyism - at least it has the advantage that it's not valid syntax for something that is completely different
(See for example the changelog where it's used extensively)
|
@bmeurant heh, there are no tests for This is looking pretty good after some tweaks! |
There was a problem hiding this comment.
This function (and the enumerable one) must be added only when the feature flag is enabled. For example:
let ArrayMixin = Mixin.create(Enumerable, {
/* snip */
});
if (isEnabled('ember-runtime-enumerable-includes')) {
ArrayMixin.reopen({
includes(obj, startAt) {
/* ... */
}
});
}
export default ArrayMixin;|
Thx for feedbacks, I'll work on it ASAP |
|
It seemed to me that Array#contains tests are also imported and run from Enumerable#contains tests. Did I miss something ? |
|
Ah I see @bmeurant :-) right there is no |
|
I wanted to add a test to verify assertion calling |
There was a problem hiding this comment.
I think we have a problem line 832 during k !== value. If the feature is enabled, without becomes inconsistent because NaN !== NaN is true
There was a problem hiding this comment.
I prefered replacing without behind feature flag to not add multiple isEnabled calls in original method
|
@bmeurant it seems ok to add a test for |
|
Thanks for your continued work on this 😄 it looks really close, and quite nice! |
|
Looking nice. A rebase/squash to some number is semantically meaningful commits (one or more) would be great, each prefixed with |
|
Done 👌 |
|
☔ The latest upstream changes (presumably #13328) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Looks pretty great to me @bmeurant! Thank you! I'll get someone else on core to review and we can |
There was a problem hiding this comment.
Should not use the global here (Ember.isNone), if we need isNone it should be imported. Can we just do the null / undefined check ourselves?
There was a problem hiding this comment.
@rwjblue using the global here was surely a mistake, sorry. isNone is already imported and used in slice. I'll update. But why do you prefer to not use imported isNone and doing null / undefined check ourselves in this case?
There was a problem hiding this comment.
Anyway, explicit null check is unnecessary as we only iterating on idx = startAt. I removed it.
|
This looks good, only one small tweak and this is good to go... |
…udes and deprecate Enumerable#contains
|
This is great! Thank you @bmeurant! |
|
FYI - I created https://github.com/rwjblue/ember-runtime-enumerable-includes-polyfill to make this a bit easier for addons to avoid deprecations, use the newer syntax, and continue to support older versions of Ember. |
Update documentation to move from contains to includes Related to emberjs/ember.js#13553. To be merged when feature has been released.
This is required as .contains seems to be deprecated in ember-3. See emberjs/ember.js#13553 for more information
Implementation of emberjs/rfcs#136
TODO :
Enumerable.includesArray.includescontainsunder feature flagcontainsbyincludes