-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Regression in behavior of delete
after 3.13 from mandatory setters
#18856
Comments
The mandatory setter changes have landed now, we should reevaluate... |
Wonder if this is fixed. |
@chriskrycho - Mind double checking (or throwing together a repro that we could use to check in on this in the future)? |
Seems to be fixed! test code to demonstrate
import Controller from "@ember/controller";
import { set } from "@ember/object";
export default class ApplicationController extends Controller {
foo;
constructor() {
super(...arguments);
set(this, "foo", "huh");
}
baleted = () => {
delete this.foo;
};
setItBack = () => {
set(this, "foo", "hey, it's back!");
};
}
<h2 id="title">
baleted
</h2>
<p>
<code>
this.foo
</code>
is
{{describe this.foo}}
</p>
<div>
<button {{on "click" this.baleted}}>
BALETED
</button>
</div>
<div>
<button {{on "click" this.setItBack}}>
Put it back
</button>
</div>
import { helper } from "@ember/component/helper";
export default helper(function describe([value] /*, hash*/) {
return value === undefined ? "undefined" : JSON.stringify(value);
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In 405d423, we introduced mandatory setters to native properties. Previously, users could call
delete this.foo
and then later callset(this, 'foo', 'some value')
, and it would work correctly. Because the setters are set on the instance (as they must be), this no longer works: if a user callsdelete this.foo
, it deletes the getter and setter, meaning that all future calls toset(this, 'foo', ...)
fail.Workaround: using
set(this, 'foo', undefined)
.Related: #18769
The text was updated successfully, but these errors were encountered: