From 4e950a903043afd7d0f532bc0f9cbb4b98e32e5f Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Fri, 23 Feb 2018 11:38:51 -0500 Subject: [PATCH] [BUGFIX beta] Ensure accessing a "proxy" itself does not error. Prior to this change, if `Ember.get` (or `this.get`) is used to access a property that is an Ember.Object with an `unknownProperty` that always returns a non-`undefined` value, the internals of `Ember.get` would check if that property is a "descriptor" and (due to the `unknownProperty` never returning `undefined`) the dev time assertion for accessing a proxy's content without using `Ember.get` would be triggered. --- packages/ember-runtime/lib/system/core_object.js | 2 ++ .../tests/system/core_object_test.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/packages/ember-runtime/lib/system/core_object.js b/packages/ember-runtime/lib/system/core_object.js index 489b1c0fcf9..4efce64b996 100644 --- a/packages/ember-runtime/lib/system/core_object.js +++ b/packages/ember-runtime/lib/system/core_object.js @@ -98,6 +98,8 @@ function makeCtor() { property === 'willWatchProperty' || property === 'didUnwatchProperty' || property === 'didAddListener' || + property === '__DESCRIPTOR__' || + property === 'isDescriptor' || property in target ) { return Reflect.get(target, property, receiver); diff --git a/packages/ember-runtime/tests/system/core_object_test.js b/packages/ember-runtime/tests/system/core_object_test.js index e0337ee111c..0e84ba6c1be 100644 --- a/packages/ember-runtime/tests/system/core_object_test.js +++ b/packages/ember-runtime/tests/system/core_object_test.js @@ -1,3 +1,4 @@ +import { get } from 'ember-metal'; import CoreObject from '../../system/core_object'; QUnit.module('Ember.CoreObject'); @@ -36,3 +37,18 @@ QUnit.test('toString should be not be added as a property when calling toString( assert.notOk(obj.hasOwnProperty('toString'), 'Calling toString() should not create a toString class property'); }); + +QUnit.test('should not trigger proxy assertion when retrieving a proxy with (GH#16263)', function(assert) { + let someProxyishThing = CoreObject.extend({ + unknownProperty() { + return true; + } + }).create(); + + let obj = new CoreObject({ + someProxyishThing + }); + + let proxy = get(obj, 'someProxyishThing'); + assert.equal(get(proxy, 'lolol'), true, 'should be able to get data from a proxy'); +});