Skip to content

Commit

Permalink
bugfix: tracked-tools#27-trigger-recomputation-on-delete
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jul 29, 2020
1 parent 57290b6 commit e264996
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions addon/-private/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ const proxyHandler = {
return true;
},

deleteProperty(target, prop) {
if (prop in target) {
delete target[prop];
dirtyKey(target, prop);
dirtyKey(target, COLLECTION);
}
return true;
},

getPrototypeOf() {
return TrackedObject.prototype;
},
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/object-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,19 @@ module('TrackedObject', function (hooks) {
}
}
);

reactivityTest(
'delete works',
class extends Component {
obj = new TrackedObject({foo: 1});

get value() {
return this.obj.foo;
}

update() {
delete this.obj.foo;
}
}
);
});

0 comments on commit e264996

Please sign in to comment.