Permalink
Browse files

Don't mark Model id as read when binding. Closes #202

  • Loading branch information...
1 parent ada24da commit 6d1a372dbc99cf54848fd0dcb5bb233fb47313ac @daffl daffl committed Dec 10, 2012
Showing with 24 additions and 3 deletions.
  1. +2 −2 model/model.js
  2. +22 −1 view/mustache/test/mustache_test.js
View
@@ -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++;
@@ -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(){
@@ -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.