Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] fix issue with overidability of computed.volatile #17431

Merged
merged 1 commit into from
Jan 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/@ember/-internals/metal/lib/computed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,12 +501,11 @@ class ComputedProperty extends Descriptor implements DescriptorWithDependentKeys

/* called before property is overridden */
teardown(obj: object, keyName: string, meta?: any): void {
if (this._volatile) {
return;
}
let cache = peekCacheFor(obj);
if (cache !== undefined && cache.delete(keyName)) {
removeDependentKeys(this, obj, keyName, meta);
if (!this._volatile) {
let cache = peekCacheFor(obj);
if (cache !== undefined && cache.delete(keyName)) {
removeDependentKeys(this, obj, keyName, meta);
}
}
super.teardown(obj, keyName, meta);
}
Expand Down
10 changes: 10 additions & 0 deletions packages/@ember/-internals/metal/tests/computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ moduleFor(
assert.equal(count, 1, 'should have invoked computed property');
}

['@test can override volatile computed property'](assert) {
let obj = {};

defineProperty(obj, 'foo', computed(function() {}).volatile());

set(obj, 'foo', 'boom');

assert.equal(obj.foo, 'boom');
}

['@test defining computed property should invoke property on set'](assert) {
let obj = {};
let count = 0;
Expand Down