From ac83f2ad2203385bb4172220788b3d1364dacb28 Mon Sep 17 00:00:00 2001 From: Katie Gengler Date: Tue, 20 Aug 2024 12:01:40 -0400 Subject: [PATCH] No longer test EXTEND_PROTOYPES .. the last usage is removed in >= 6.0 --- .github/workflows/ci.yml | 8 ---- bin/run-tests.js | 4 -- index.html | 3 -- .../@ember/-internals/environment/lib/env.ts | 4 +- packages/@ember/array/index.ts | 42 +++++++------------ 5 files changed, 16 insertions(+), 45 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c377894f24..208e5f263cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 }} diff --git a/bin/run-tests.js b/bin/run-tests.js index 83087ed9583..44687d9f46f 100755 --- a/bin/run-tests.js +++ b/bin/run-tests.js @@ -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', diff --git a/index.html b/index.html index c6fad19b48a..81c2569d2ba 100644 --- a/index.html +++ b/index.html @@ -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; diff --git a/packages/@ember/-internals/environment/lib/env.ts b/packages/@ember/-internals/environment/lib/env.ts index 74627d17241..d64eac6c7d8 100644 --- a/packages/@ember/-internals/environment/lib/env.ts +++ b/packages/@ember/-internals/environment/lib/env.ts @@ -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, }, /** diff --git a/packages/@ember/array/index.ts b/packages/@ember/array/index.ts index 2a07aa2fbf7..326c9d8b1fc 100644 --- a/packages/@ember/array/index.ts +++ b/packages/@ember/array/index.ts @@ -2094,34 +2094,20 @@ NativeArray = NativeArray.without(...ignore); let A: (arr?: Array) => NativeArray; -if (ENV.EXTEND_PROTOTYPES.Array) { - NativeArray.apply(Array.prototype, true); - - A = function (this: unknown, arr?: Array) { - 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; - }; -} else { - A = function (this: unknown, arr?: Array) { - 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; - } else { - // SAFETY: This will return an NativeArray but TS can't infer that. - return NativeArray.apply(arr ?? []) as NativeArray; - } - }; -} +A = function (this: unknown, arr?: Array) { + 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; + } else { + // SAFETY: This will return an NativeArray but TS can't infer that. + return NativeArray.apply(arr ?? []) as NativeArray; + } +}; export { A, NativeArray, MutableArray };