Skip to content

Commit

Permalink
[BUGFIX beta] Ensure accessing a "proxy" itself does not error.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rwjblue committed Feb 23, 2018
1 parent 3a537b5 commit 4e950a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/ember-runtime/lib/system/core_object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions packages/ember-runtime/tests/system/core_object_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { get } from 'ember-metal';
import CoreObject from '../../system/core_object';

QUnit.module('Ember.CoreObject');
Expand Down Expand Up @@ -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');
});

0 comments on commit 4e950a9

Please sign in to comment.