Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Prevent setting of __nextSuper on frozen objects #5374

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions packages/ember-metal/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ export function metaPath(obj, path, writable) {
export function wrap(func, superFunc) {
function superWrapper() {
var ret, sup = this && this.__nextSuper;
if(this) { this.__nextSuper = superFunc; }
setSuper(this, superFunc);
ret = apply(this, func, arguments);
if(this) { this.__nextSuper = sup; }
setSuper(this, sup);
return ret;
}

Expand All @@ -406,6 +406,10 @@ export function wrap(func, superFunc) {
superWrapper.__ember_listens__ = func.__ember_listens__;

return superWrapper;

function setSuper(obj, superFunc) {
if(obj && !Object.isFrozen(obj)) { obj.__nextSuper = superFunc; }
}
}

var EmberArray;
Expand Down
6 changes: 6 additions & 0 deletions packages/ember-runtime/tests/mixins/enumerable_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ test('every', function() {
equal(allWhite, true);
});

test('contains on frozen array', function(){
var arr = Ember.A(["foo", "bar", "baz"]);
Object.freeze(arr);
equal(arr.contains("foo"), true);
});

// ..........................................................
// CONTENT DID CHANGE
//
Expand Down