@@ -17,7 +17,6 @@ import { assert } from '@ember/debug';
1717import Enumerable from '@ember/enumerable' ;
1818import MutableEnumerable from '@ember/enumerable/mutable' ;
1919import { compare , typeOf } from '@ember/utils' ;
20- import { ENV } from '@ember/-internals/environment' ;
2120import Observable from '@ember/object/observable' ;
2221import type { MethodNamesOf , MethodParams , MethodReturns } from '@ember/-internals/utility-types' ;
2322import type { ComputedPropertyCallback } from '@ember/-internals/metal' ;
@@ -1858,11 +1857,7 @@ const MutableArray = Mixin.create(EmberArray, MutableEnumerable, {
18581857
18591858/**
18601859 Creates an `Ember.NativeArray` from an Array-like object.
1861- Does not modify the original object's contents. `A()` is not needed if
1862- `EmberENV.EXTEND_PROTOTYPES` is `true` (the default value). However,
1863- it is recommended that you use `A()` when creating addons for
1864- ember or when you can not guarantee that `EmberENV.EXTEND_PROTOTYPES`
1865- will be `true`.
1860+ Does not modify the original object's contents.
18661861
18671862 Example
18681863
@@ -2061,10 +2056,7 @@ interface MutableArrayWithoutNative<T>
20612056
20622057/**
20632058 The NativeArray mixin contains the properties needed to make the native
2064- Array support MutableArray and all of its dependent APIs. Unless you
2065- have `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Array` set to
2066- false, this will be applied automatically. Otherwise you can apply the mixin
2067- at anytime by calling `Ember.NativeArray.apply(Array.prototype)`.
2059+ Array support MutableArray and all of its dependent APIs.
20682060
20692061 @class Ember.NativeArray
20702062 @uses MutableArray
@@ -2101,34 +2093,20 @@ NativeArray = NativeArray.without(...ignore);
21012093
21022094let A : < T > ( arr ?: Array < T > ) => NativeArray < T > ;
21032095
2104- if ( ENV . EXTEND_PROTOTYPES . Array ) {
2105- NativeArray . apply ( Array . prototype , true ) ;
2106-
2107- A = function < T > ( this : unknown , arr ?: Array < T > ) {
2108- assert (
2109- 'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`' ,
2110- ! ( this instanceof A )
2111- ) ;
2112-
2113- // SAFTEY: Since we are extending prototypes all true native arrays are Ember NativeArrays
2114- return ( arr || [ ] ) as NativeArray < T > ;
2115- } ;
2116- } else {
2117- A = function < T > ( this : unknown , arr ?: Array < T > ) {
2118- assert (
2119- 'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`' ,
2120- ! ( this instanceof A )
2121- ) ;
2122-
2123- if ( isEmberArray ( arr ) ) {
2124- // SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray
2125- return arr as unknown as NativeArray < T > ;
2126- } else {
2127- // SAFETY: This will return an NativeArray but TS can't infer that.
2128- return NativeArray . apply ( arr ?? [ ] ) as NativeArray < T > ;
2129- }
2130- } ;
2131- }
2096+ A = function < T > ( this : unknown , arr ?: Array < T > ) {
2097+ assert (
2098+ 'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`' ,
2099+ ! ( this instanceof A )
2100+ ) ;
2101+
2102+ if ( isEmberArray ( arr ) ) {
2103+ // SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray
2104+ return arr as unknown as NativeArray < T > ;
2105+ } else {
2106+ // SAFETY: This will return an NativeArray but TS can't infer that.
2107+ return NativeArray . apply ( arr ?? [ ] ) as NativeArray < T > ;
2108+ }
2109+ } ;
21322110
21332111export { A , NativeArray , MutableArray } ;
21342112
0 commit comments