Skip to content

Commit

Permalink
[BUGFIX release] avoid strict assertion when object proxy calls thru …
Browse files Browse the repository at this point in the history
…for function
  • Loading branch information
toranb committed Apr 22, 2018
1 parent 953f677 commit 5d7da91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ function makeCtor(base) {

let value = target.unknownProperty.call(receiver, property);

assert(messageFor(receiver, property), value === undefined || value === null);
if (typeof value !== 'function') {
assert(messageFor(receiver, property), value === undefined || value === null);
}
},
});

Expand Down
25 changes: 25 additions & 0 deletions packages/ember-runtime/tests/system/object_proxy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ moduleFor(
assert.equal(JSON.stringify(proxy), JSON.stringify({ content: { foo: 'FOO' } }));
}

['@test calling a function on the proxy avoids the assertion'](assert) {
if (DEBUG && HAS_NATIVE_PROXY) {
let proxy = ObjectProxy.extend({
init() {
if (!this.foobar) {
this.foobar = function() {
let content = get(this, 'content');
return content.foobar.apply(content, []);
};
}
},
}).create({
content: {
foobar() {
return 'xoxo';
},
},
});

assert.equal(proxy.foobar(), 'xoxo', 'should be able to use a function from a proxy');
} else {
assert.expect(0);
}
}

[`@test setting a property on the proxy avoids the assertion`](assert) {
let proxy = ObjectProxy.create({
toJSON: undefined,
Expand Down

0 comments on commit 5d7da91

Please sign in to comment.