diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6e3edd2..7b4fd04e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.5.2 * Observable objects can now have a type: `IObservableObject`, see [#484](https://github.com/mobxjs/mobx/pull/484) by @spiffytech +* Restored 2.4 behavior of boxed observables inside observable objects, see [#558](https://github.com/mobxjs/mobx/issues/558) # 2.5.1 diff --git a/src/types/observableobject.ts b/src/types/observableobject.ts index b526bdeb5..b52ca4a7e 100644 --- a/src/types/observableobject.ts +++ b/src/types/observableobject.ts @@ -89,11 +89,10 @@ export function defineObservableProperty(adm: ObservableObjectAdministration, pr let name = `${adm.name}.${propName}`; let isComputed = true; - if (newValue instanceof ObservableValue) { - observable = newValue; - newValue.name = name; - isComputed = false; - } else if (newValue instanceof ComputedValue) { + if (newValue instanceof ComputedValue) { + // desugger computed(getter, setter) + // TODO: deprecate this and remove in 3.0, to keep them boxed + // get / set is now the idiomatic syntax for non-boxed computed values observable = newValue; newValue.name = name; if (!newValue.scope) diff --git a/test/observables.js b/test/observables.js index 65fad621e..bfe4d8b5b 100644 --- a/test/observables.js +++ b/test/observables.js @@ -1892,3 +1892,13 @@ test('helpful error for self referencing setter', function(t) { t.end() }) + +test('#558 boxed observables stay boxed observables', function(t) { + var a = observable({ + x: observable(3) + }) + + t.equal(typeof a.x, "object") + t.equal(typeof a.x.get, "function") + t.end() +})