From 5d7da91d03ea7323de38df00bf91736dc3abdaab Mon Sep 17 00:00:00 2001 From: toran billups Date: Sat, 21 Apr 2018 21:41:31 -0500 Subject: [PATCH] [BUGFIX release] avoid strict assertion when object proxy calls thru for function --- .../ember-runtime/lib/system/core_object.js | 4 ++- .../tests/system/object_proxy_test.js | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/ember-runtime/lib/system/core_object.js b/packages/ember-runtime/lib/system/core_object.js index 8e8911dacea..24241d30439 100644 --- a/packages/ember-runtime/lib/system/core_object.js +++ b/packages/ember-runtime/lib/system/core_object.js @@ -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); + } }, }); diff --git a/packages/ember-runtime/tests/system/object_proxy_test.js b/packages/ember-runtime/tests/system/object_proxy_test.js index 0fafcf4dc9c..6082d327ce1 100644 --- a/packages/ember-runtime/tests/system/object_proxy_test.js +++ b/packages/ember-runtime/tests/system/object_proxy_test.js @@ -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,