Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed Jul 30, 2019
1 parent 15b7910 commit 7892e34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/@ember/-internals/metal/lib/computed.ts
Expand Up @@ -541,6 +541,8 @@ export class ComputedProperty extends ComputedDescriptor {
let ret;

if (EMBER_METAL_TRACKED_PROPERTIES) {
// For backwards compatibility, we only throw if the CP has any dependencies. CPs without dependencies
// should be allowed, even after the object has been destroyed, which is why we check _dependentKeys.
assert(
`Attempted to access the computed ${obj}.${keyName} on a destroyed object, which is not allowed`,
this._dependentKeys === undefined || !metaFor(obj).isMetaDestroyed()
Expand Down
17 changes: 17 additions & 0 deletions packages/@ember/-internals/metal/tests/computed_test.js
Expand Up @@ -604,6 +604,23 @@ moduleFor(

expectAssertion(() => get(obj, 'foo'), message);
}

['@test does not throw an assertion if an uncached `get` is called on computed without dependencies after object is destroyed'](
assert
) {
let meta = metaFor(obj);
defineProperty(
obj,
'foo',
computed(function() {
return 'baz';
})
);

meta.destroy();

assert.equal(get(obj, 'foo'), 'baz', 'CP calculated successfully');
}
}
);

Expand Down

0 comments on commit 7892e34

Please sign in to comment.