Skip to content

Commit ed1f158

Browse files
authored
Update disabling-prototype-extensions.md with possible fix for #20465
emberjs/ember.js#20465 See https://github.com/ember-cli/ember-cli/blob/master/CHANGELOG.md#v490
1 parent 51de385 commit ed1f158

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

guides/v4.9.0/configuring-ember/disabling-prototype-extensions.md

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,13 @@
1-
By default, Ember.js will extend the prototypes of native JavaScript
2-
arrays to implement the `Ember.Enumerable`, `Ember.MutableEnumerable`,
3-
`Ember.MutableArray` and `Ember.Array` interfaces. This polyfills
4-
ECMAScript 5 array methods in browsers that do not implement them, adds
5-
convenience methods and properties to built-in arrays, and makes array
6-
mutations observable.
7-
8-
This is the extent to which Ember.js enhances native prototypes. We have
9-
carefully weighed the trade-offs involved with changing these prototypes,
10-
and recommend that most Ember.js developers use them. These extensions
11-
significantly reduce the amount of boilerplate code that must be typed.
12-
13-
However, we understand that there are cases where your Ember.js
14-
application may be embedded in an environment beyond your control. The
15-
most common scenarios are when authoring third-party JavaScript that is
16-
embedded directly in other pages, or when transitioning an application
17-
piecemeal to a more modern Ember.js architecture.
18-
19-
In those cases, where you can't or don't want to modify native
20-
prototypes, Ember.js allows you to completely disable the extensions
21-
described above.
22-
23-
To do so, simply set the `EmberENV.EXTEND_PROTOTYPES` flag to `false`:
1+
Historically, Ember.js extended the prototypes of native JavaScript arrays to implement the Ember.Enumerable, Ember.MutableEnumerable, Ember.MutableArray, and Ember.Array interfaces. This added convenience methods and properties to built-in arrays, and made array mutations observable.
2+
3+
However, as of Ember-cli 4.9.0, prototype extensions are disabled by default in new Ember applications. This change was made to align more closely with standard JavaScript behavior and to avoid potential conflicts with other libraries or future language features.
4+
5+
If you have an existing application that relies on prototype extensions, you can still enable them by setting the `EmberENV.EXTEND_PROTOTYPES` flag to `true` in your `config/environment.js` file:
246

257
```javascript {data-filename=config/environment.js}
268
ENV = {
279
EmberENV: {
28-
EXTEND_PROTOTYPES: false
10+
EXTEND_PROTOTYPES: true
2911
}
3012
}
3113
```
@@ -37,7 +19,7 @@ for in your application's configuration like so:
3719
ENV = {
3820
EmberENV: {
3921
EXTEND_PROTOTYPES: {
40-
Array: false
22+
Array: true
4123
}
4224
}
4325
}

0 commit comments

Comments
 (0)