File tree Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ - Start Date: 2016-04-16
2
+ - RFC PR: (leave this empty)
3
+ - Ember Issue: (leave this empty)
4
+
5
+ # Summary
6
+
7
+ [ ` contains ` ] ( http://emberjs.com/api/classes/Ember.Array.html#method_contains ) is
8
+ implemented on ` Ember.Array ` , but [ contains was renamed to includes in 2014]
9
+ (https://github.com/tc39/Array.prototype.includes/commit/4b6b9534582cb7991daea3980c26a34af0e76c6c )
10
+ - this proposal is for ` contains ` to be deprecated in favour of an ` includes `
11
+ method on ` Ember.Array `
12
+
13
+ # Motivation
14
+
15
+ Motivation is to stay in line with web standards
16
+
17
+ # Detailed design
18
+
19
+ First, implement ` includes ` polyfill in compliance with ` includes ` spec. Polyfill
20
+ sample from MDN is:
21
+
22
+ ``` js
23
+ if (! Array .prototype .includes ) {
24
+ Array .prototype .includes = function (searchElement /* , fromIndex*/ ) {
25
+ ' use strict' ;
26
+ var O = Object (this );
27
+ var len = parseInt (O .length ) || 0 ;
28
+ if (len === 0 ) {
29
+ return false ;
30
+ }
31
+ var n = parseInt (arguments [1 ]) || 0 ;
32
+ var k;
33
+ if (n >= 0 ) {
34
+ k = n;
35
+ } else {
36
+ k = len + n;
37
+ if (k < 0 ) {k = 0 ;}
38
+ }
39
+ var currentElement;
40
+ while (k < len) {
41
+ currentElement = O [k];
42
+ if (searchElement === currentElement ||
43
+ (searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN
44
+ return true ;
45
+ }
46
+ k++ ;
47
+ }
48
+ return false ;
49
+ };
50
+ }
51
+ ```
52
+
53
+ Then, alias ` contains ` to ` includes ` with deprecation warning, deprecate in line with standard
54
+ deprecation process. I don't believe that adding the additional parameter will
55
+ have any affect on existing usage of ` contains ` .
56
+
57
+ # How We Teach This
58
+
59
+ Update any references in docs and guides to ` includes `
60
+
61
+ # Drawbacks
62
+
63
+ * May break existing apps
64
+ * [ Was considered before but was too early] ( https://github.com/emberjs/ember.js/issues/5670#issuecomment-64084814 )
65
+
66
+ # Alternatives
67
+
68
+ Keep current methods
69
+
70
+ # Unresolved questions
71
+
72
+ None
You can’t perform that action at this time.
0 commit comments