Skip to content

Commit

Permalink
fix accessing properties of Object Proxy (emberjs#1092)
Browse files Browse the repository at this point in the history
* fix access of Object Proxy

also for tracked detection

* Update object-inspector-test.js
  • Loading branch information
patricklx authored and nummi committed Apr 1, 2020
1 parent 669c56a commit 86f2f68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 8 additions & 7 deletions ember_debug/object-inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,6 @@ export default EmberObject.extend(PortMixin, {
*/
mixinDetailsForObject(object) {
const mixins = [];
if (object instanceof Ember.ObjectProxy && object.content && !object._showProxyDetails) {
return this.mixinDetailsForObject(object.content);
}

if (object instanceof Ember.ArrayProxy && object.content && !object._showProxyDetails) {
return this.mixinDetailsForObject(object.slice(0, 101));
}

const own = ownMixins(object);

Expand Down Expand Up @@ -611,6 +604,14 @@ export default EmberObject.extend(PortMixin, {
},

mixinsForObject(object) {
if (object instanceof Ember.ObjectProxy && object.content && !object._showProxyDetails) {
object = object.content;
}

if (object instanceof Ember.ArrayProxy && object.content && !object._showProxyDetails) {
object = object.slice(0, 101);
}

let mixinDetails = this.mixinDetailsForObject(object);

mixinDetails[0].name = 'Own Properties';
Expand Down
9 changes: 8 additions & 1 deletion tests/ember_debug/object-inspector-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ module('Ember Debug - Object Inspector', function(hooks) {

test('Proxies are skipped by default', function (assert) {
let inspected = EmberObject.extend({
test: 'a'
test: 'a',
get abc() {
return 1;
}
}).create();
const proxy = ObjectProxy.create({
content: inspected
Expand All @@ -285,6 +288,10 @@ module('Ember Debug - Object Inspector', function(hooks) {
let computedProperty = message.details[1].properties[0];
assert.equal(computedProperty.name, 'test');
assert.equal(computedProperty.value.inspect, inspect('a'));

let getterProperty = message.details[1].properties[1];
assert.equal(getterProperty.name, 'abc');
assert.equal(getterProperty.value.inspect, inspect(1));
});

test('Object Proxies are not skipped with _showProxyDetails', function (assert) {
Expand Down

0 comments on commit 86f2f68

Please sign in to comment.