($click)=“handler()”
DefineMap
, then you want `set: http://canjs.com/doc/can-define/map/map.prototype.set.html
{{#../teams.getById(homeTeamId)}}
how does that work? besides the fact that I only thought possible to use {{#keyword}}
with a reduced number of words there is also a parametric way of choosing that keyword? what about closing that tag, isn’t that necessary? thanks
Hi!
I don't know if I'm missing something or there is a memory leak in CanJs 3.
Following these steps anyone can reproduce the problem (I'm using Google Chrome):
Does anyone know what alternative I have to the change event in canjs 3?
Say I have a list of foo's on my viewModel, and I want to listen to a change on any of the list "value" properties. I.e. how do I write this in canjs 3:
"{viewModel.foos} change" : function ( foos, event, prop ) {
if ( prop.indexOf( "value" !== -1 )) { ... }
}
Hello!
I've further investigated the memory problem. It seems to me that can-util/dom/data/data causes the leak.
In data.js there is a variable 'data' that stores objects by id.
As I could understand the problem lies in not cleaning the 'data' variable.
To put everything in context: we have a quite large app (19 000 LOC) that is built with CanJS 2.x.
We are happy with it and started to migrate to 3.x.
We are at the final steps of migration and now we realized that with CanJS 3 we have a memory leaking problem.
I've created a small sample app that compares CanJS 2 and 3 regarding memory usage:
gist link
Repeating these steps with index_canjs3.html show that the number of listeners grow gradually (with 3 Insert/Remove cycle the number of listeners grows from 4->10)!
If you put a breakpoint at the 753. row of can.all.js and analyze the content of variable 'data' (in Closure) after you click on Insert, you can see, that after a few "click on Insert/click on Remove" cycle 'data' keeps growing.
Initially - at the first click on Insert - there are 3 items in it.
Clicking Insert for the second time the 'data' variable contains 8 item.
When I click on Insert for the sixth time 'data' contains 28 objects!
No object gets removed from it.
This causes a memory leak: there are detached HTMLAnchorElements which cannot be GC-d because 'data' keeps reference for objects (canAttributesObserver, MutationObserver) which reference these HTML objects.
Shouldn't 'data' contain only objects that are somehow related to objects live in the DOM?
Is there something I'm doing wrong regarding the component insertion and removal?
Thank you in advance!
also, does this memory leak happen if you instead of
var frag = template(new TestVM());
document.body.appendChild(frag);
you do
var myCompFrag = myCompRenderer();
document.body.appendChild(myCompFrag);