-
-
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
[BUGFIX release-1-13] Do not require _super in didRecieveAttrs. #12138
[BUGFIX release-1-13] Do not require _super in didRecieveAttrs. #12138
Conversation
Default framework hooks should not *require* that users call `this._super` (however, it is still a best practice). This adds a new `_internalDidReceiveAttrs` hook for use internally to avoid using a `didRecieveAttrs` in `AttrsProxy`.
…eceive-attrs [BUGFIX release-1-13] Do not require _super in didRecieveAttrs.
In case anyone wants to know, it is good practice because:
|
@rwjblue @poteto quick question related to this. If I have a base component that hooks into // base component
Ember.Component.extend({
Ember.on('didReceiveAttrs', function() {
// do some awesome stuff
})
});
// extends base component
BaseComponent.extend({
Ember.on('didReceiveAttrs', function() {
// awesome stuff specific to this component
// do I need to call this._super() here if I need to use the BaseComponent functionality as well?
})
}); |
No, you only need to call super when overriding an existing method on a parent class. Using E.g. BaseComponent.extend({
doStuff: Ember.on('didReceiveAttrs', function() {
// no super call required, as `doStuff` is not a method on the parent class
}),
didInsertElement() {
this._super(...arguments); // overriding an existing method on the parent class
},
willDestroyElement: Ember.on(/* ... */) // don't do this
});
// extends from BaseComponent
ChildComponent.extend({
doStuff() {
this._super(...arguments); // if you want to preserve BaseComponent's `doStuff` method
}
}); |
Thank you @poteto! |
what @rwjblue said! |
Due to emberjs/ember.js#12138 the library doesn't currently support older versions of ember
Default framework hooks should not require that users call
this._super
(however, it is still a best practice).This adds a new
_internalDidReceiveAttrs
hook for use internally to avoid using adidRecieveAttrs
inAttrsProxy
.Fixes #11992.