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

[BUGFIX release] avoid strict assertion when object proxy calls thru for function #16560

Merged
merged 1 commit into from
Apr 22, 2018
Merged
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
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