Skip to content

Commit

Permalink
No longer test EXTEND_PROTOYPES .. the last usage is removed in >= 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kategengler committed Aug 20, 2024
1 parent c7b9ef2 commit ac83f2a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 45 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,6 @@ jobs:
- name: "Production build, with optional features"
BUILD: "production"
ENABLE_OPTIONAL_FEATURES: "true"
- name: "Extend prototypes"
EXTEND_PROTOTYPES: "true"
RAISE_ON_DEPRECATION: "false"
- name: "Extend prototypes, with optional features"
EXTEND_PROTOTYPES: "true"
ENABLE_OPTIONAL_FEATURES: "true"
RAISE_ON_DEPRECATION: "false"

steps:
- uses: actions/checkout@v4
Expand All @@ -115,7 +108,6 @@ jobs:
env:
ALL_DEPRECATIONS_ENABLED: ${{ matrix.ALL_DEPRECATIONS_ENABLED }}
OVERRIDE_DEPRECATION_VERSION: ${{ matrix.OVERRIDE_DEPRECATION_VERSION }}
EXTEND_PROTOTYPES: ${{ matrix.EXTEND_PROTOTYPES }}
ENABLE_OPTIONAL_FEATURES: ${{ matrix.ENABLE_OPTIONAL_FEATURES }}
RAISE_ON_DEPRECATION: ${{ matrix.RAISE_ON_DEPRECATION }}

Expand Down
4 changes: 0 additions & 4 deletions bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ const variants = [
// hit its "until" version, the tests for it will behave correctly.
'OVERRIDE_DEPRECATION_VERSION',

// This enables the legacy Ember feature that causes Ember to extend built-in
// platform features like Array.
'EXTEND_PROTOTYPES',

// This enables all canary feature flags for unreleased feature within Ember
// itself.
'ENABLE_OPTIONAL_FEATURES',
Expand Down
3 changes: 0 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
EmberENV.__test_hook_count__ += object;
});

// Handle extending prototypes
EmberENV['EXTEND_PROTOTYPES'] = !!QUnit.urlParams.EXTEND_PROTOTYPES;

// Handle testing feature flags
if (QUnit.urlParams.ENABLE_OPTIONAL_FEATURES) {
EmberENV.ENABLE_OPTIONAL_FEATURES = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/-internals/environment/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export const ENV = {
@type Boolean
@default true
@for EmberENV
@public
@private
@deprecated in v5.10
*/
EXTEND_PROTOTYPES: {
Array: true,
Array: false,
},

/**
Expand Down
42 changes: 14 additions & 28 deletions packages/@ember/array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2094,34 +2094,20 @@ NativeArray = NativeArray.without(...ignore);

let A: <T>(arr?: Array<T>) => NativeArray<T>;

if (ENV.EXTEND_PROTOTYPES.Array) {
NativeArray.apply(Array.prototype, true);

A = function <T>(this: unknown, arr?: Array<T>) {
assert(
'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`',
!(this instanceof A)
);

// SAFTEY: Since we are extending prototypes all true native arrays are Ember NativeArrays
return (arr || []) as NativeArray<T>;
};
} else {
A = function <T>(this: unknown, arr?: Array<T>) {
assert(
'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`',
!(this instanceof A)
);

if (isEmberArray(arr)) {
// SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray
return arr as unknown as NativeArray<T>;
} else {
// SAFETY: This will return an NativeArray but TS can't infer that.
return NativeArray.apply(arr ?? []) as NativeArray<T>;
}
};
}
A = function <T>(this: unknown, arr?: Array<T>) {
assert(
'You cannot create an Ember Array with `new A()`, please update to calling A as a function: `A()`',
!(this instanceof A)
);

if (isEmberArray(arr)) {
// SAFETY: If it's a true native array and it is also an EmberArray then it should be an Ember NativeArray
return arr as unknown as NativeArray<T>;
} else {
// SAFETY: This will return an NativeArray but TS can't infer that.
return NativeArray.apply(arr ?? []) as NativeArray<T>;
}
};

export { A, NativeArray, MutableArray };

Expand Down

0 comments on commit ac83f2a

Please sign in to comment.