-
Notifications
You must be signed in to change notification settings - Fork 18
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
fix(components) $dispose not always called #306
base: master
Are you sure you want to change the base?
Conversation
fa83f40
to
a4d9770
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behinf `data.ref` corresponding `$dispose()` method (if any defined in the controller class) were not executed. Closes ariatemplates#306
a4d9770
to
d245a52
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behinf `data.ref` corresponding `$dispose()` method (if any defined in the controller class) were not executed. Closes ariatemplates#306
@@ -600,11 +600,19 @@ var $CptNode = klass({ | |||
if (tplChanged) { | |||
// check if component nature changed from template to component or opposite | |||
this.template=tpl; | |||
// Change might also be a different component ref, ie cpt1 -> cpt2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not enough as apparently the $dispose method is not called on the template root node (cf. $root.js line 120). So we should keep a reference on the template root node (which is returned when the template function is called) and call $dispose() on this reference. This should both dispose the node chain and the controller
(sorry I just realize this now!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is somehow valid, but could be done in another PR.
Nevertheless, the $RootNode.$dispose
method as far as I get it is only called when we don't want to keep localProperties
on the node itself.
/**
* Default dispose method
* @param {Boolean} localPropOnly if true only local properties will be deleted (optional)
* must be used when a new instance is created to adapt to a path change
*/
$dispose:function(localPropOnly) {
this.cleanObjectProperties(localPropOnly);
},
/**
* Removes object properties - helper for $dispose methods
* @param {Boolean} localPropOnly if true only local properties will be deleted (optional)
* must be used when a new instance is created to adapt to a path change
*/
cleanObjectProperties : function (localPropOnly) {
this.removePathObservers();
if (this._scopeChgeCb) {
json.unobserve(this.vscope, this._scopeChgeCb);
this._scopeChgeCb = null;
}
if (localPropOnly!==true) {
$RootNode.$dispose.call(this);
}
this.exps = null;
this.controller = null;
this.ctlAttributes = null;
this.template = null;
if (this.node1) {
this.node1=null;
this.node2=null;
}
}
d245a52
to
95d5dcb
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behind `data.ref` corresponding `$dispose()` method (if any defined in the controller class) was not executed. Closes ariatemplates#306
95d5dcb
to
59b89c0
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behind `data.ref` corresponding `$dispose()` method (if any defined in the controller class) was not executed. Closes ariatemplates#306
59b89c0
to
7d44055
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behind `data.ref` corresponding `$dispose()` method (if any defined in the controller class) was not executed. Closes ariatemplates#306
7d44055
to
f7c5c35
Compare
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behind `data.ref` corresponding `$dispose()` method (if any defined in the controller class) was not executed. Closes ariatemplates#306
Let's consider a template like that ``` <template test(data)> <#data.ref /> </template> ``` When changing the component template behind `data.ref` corresponding `$dispose()` method (if any defined in the controller class) was not executed. Closes ariatemplates#306
f7c5c35
to
e751e80
Compare
Let's consider a template like that
When changing the component template behinf
data.ref
corresponding$dispose()
method (if any defined in the controller class) were notexecuted.