}
const readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name;
-const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters';
+const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters' &&
+ (Object.getPrototypeOf(value) === null || value.constructor === Object);
function _cached(target, prop, resolve) {
if (Object.prototype.hasOwnProperty.call(target, prop)) {
_stack.add(prop);
value = value(_context, _subProxy || receiver);
_stack.delete(prop);
- if (isObject(value)) {
+ if (needsSubResolver(prop, value)) {
// When scriptable option returns an object, create a resolver on that.
value = createSubResolver(_proxy._scopes, _proxy, prop, value);
}
expect(fn()).toEqual('ok');
});
+ it('should not create proxy for objects with custom constructor', function() {
+ class MyClass {
+ constructor() {
+ this.string = 'test string';
+ }
+ method(arg) {
+ return arg === undefined ? 'ok' : 'fail';
+ }
+ }
+
+ const defaults = {
+ test: new MyClass()
+ };
+
+ const resolver = _createResolver([{}, defaults]);
+ const opts = _attachContext(resolver, {index: 1});
+ const fn = opts.test.method;
+ expect(typeof fn).toBe('function');
+ expect(fn()).toEqual('ok');
+ expect(opts.test.string).toEqual('test string');
+ expect(opts.test.constructor).toEqual(MyClass);
+ });
+
it('should properly set value to object in array of objects', function() {
const defaults = {};
const options = {