Skip to content

Commit e8dd6fa

Browse files
patricklxBlueCutOfficialRobbieTheWagner
authored
fix service detection (#2664)
Co-authored-by: Marine Dunstetter <[email protected]> Co-authored-by: Robbie Wagner <[email protected]>
1 parent f553044 commit e8dd6fa

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

ember_debug/object-inspector.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -899,18 +899,7 @@ function addProperties(properties, hash) {
899899
let options = { isMandatorySetter: isMandatorySetter(desc) };
900900

901901
if (typeof hash[prop] === 'object' && hash[prop] !== null) {
902-
options.isService =
903-
!('type' in hash[prop]) && hash[prop].type === 'service';
904-
905-
if (!options.isService) {
906-
if (hash[prop].constructor) {
907-
options.isService = hash[prop].constructor.isServiceFactory;
908-
}
909-
}
910-
911-
if (!options.isService) {
912-
options.isService = desc.value instanceof Service;
913-
}
902+
options.isService = desc.value instanceof Service;
914903
}
915904
if (options.isService) {
916905
replaceProperty(properties, prop, inspectValue(hash, prop), options);
@@ -1112,6 +1101,9 @@ function calculateCPs(
11121101
item.code = '';
11131102
}
11141103
}
1104+
if (value instanceof Service) {
1105+
item.isService = true;
1106+
}
11151107
}
11161108
}
11171109
});

tests/ember_debug/object-inspector-test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import EmberObject, { computed } from '@ember/object';
1111
import MutableArray from '@ember/array/mutable';
1212
import ArrayProxy from '@ember/array/proxy';
1313
import ObjectProxy from '@ember/object/proxy';
14-
import Service from '@ember/service';
14+
import Service, { inject as service } from '@ember/service';
1515
import { VERSION } from '@ember/version';
1616
import { tracked } from '@glimmer/tracking';
1717
import { module, skip, test } from 'qunit';
@@ -902,17 +902,22 @@ module('Ember Debug - Object Inspector', function (hooks) {
902902
fooBoo() {
903903
return true;
904904
},
905-
}).create();
905+
});
906+
907+
this.owner.register('service:test-inspect-service', inspectedService);
906908

907909
let inspected = EmberObject.extend({
908-
service: inspectedService,
909-
}).create();
910+
service: inspectedService.create(),
911+
service2: service('test-inspect-service'),
912+
}).create(this);
910913

911914
let message = await inspectObject(inspected);
912915

913916
let serializedServiceProperty = message.details[1].properties[0];
917+
let serializedService2Property = message.details[1].properties[1];
914918

915919
assert.true(serializedServiceProperty.isService);
920+
assert.true(serializedService2Property.isService);
916921
});
917922

918923
test('Proxy Service should be successfully tagged as service on serialization', async function (assert) {

0 commit comments

Comments
 (0)