Skip to content

Commit

Permalink
Don't mark Model id as read when binding. Closes #202
Browse files Browse the repository at this point in the history
  • Loading branch information
daffl committed Dec 10, 2012
1 parent ada24da commit 6d1a372
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 2 additions & 2 deletions model/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,10 @@ steal('can/util','can/observe', function( can ) {
* model instance is removed from the store, freeing memory.
*
*/
bind : function(eventName){
bind: function(eventName){
if ( ! ignoreHookup.test( eventName )) {
if ( ! this._bindings ) {
this.constructor.store[getId(this)] = this;
this.constructor.store[this.__get(this.constructor.id)] = this;
this._bindings = 0;
}
this._bindings++;
Expand Down
23 changes: 22 additions & 1 deletion view/mustache/test/mustache_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
steal('funcunit/syn', 'can/view/mustache', function(){
steal('funcunit/syn', 'can/view/mustache', 'can/model', function(){

module("can/view/mustache, rendering",{
setup : function(){
Expand Down Expand Up @@ -1251,4 +1251,25 @@ test("computes as helper parameters do get converted", function() {
});
})

test("Rendering models in tables produces different results than an equivalent observe (#202)", 2, function() {
var renderer = can.view.mustache('<table>{{#stuff}}<tbody>{{#rows}}<tr></tr>{{/rows}}</tbody>{{/stuff}}</table>');
var div = document.createElement('div');
var dom = renderer({
stuff : new can.Observe({
rows: [{ name : 'first' }]
})
});
div.appendChild(dom);
same(div.innerHTML, "<table><tbody><tr></tr></tbody></table>", "Observe generated expected HTML");

div = document.createElement('div');
dom = renderer({
stuff : new can.Model({
rows: [{ name : 'first' }]
})
});
div.appendChild(dom);
same(div.innerHTML, "<table><tbody><tr></tr></tbody></table>", "Model generated expected HTML");
})

});

0 comments on commit 6d1a372

Please sign in to comment.