Skip to content

Commit

Permalink
fixes bugs in IE for mootools
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed Jan 26, 2013
1 parent 58f1035 commit 6bb9c7d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 4 additions & 1 deletion util/mootools/mootools.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,15 @@ steal('can/util/can.js', 'mootools', 'can/util/event.js','can/util/fragment.js',
}
// Make this object so you can bind on it.
can.bind = function( ev, cb){

// If we can bind to it...
if(this.bind && this.bind !== can.bind){
this.bind(ev, cb)
} else if(this.addEvent) {
this.addEvent(ev, cb)
} else {
} else if(this.nodeName && this.nodeType) {
$(this).addEvent(ev, cb)
}else {
// Make it bind-able...
can.addEvent.call(this, ev, cb)
}
Expand Down
1 change: 1 addition & 0 deletions view/ejs/ejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ steal('can/util', 'can/view', 'can/util/string', 'can/observe/compute', 'can/vie
*/
// TODO Deprecated!!
list : function(list, cb){
console.log("calling list "+list.length);
can.each(list, function(item, i){
cb(item, i, list)
})
Expand Down
10 changes: 5 additions & 5 deletions view/ejs/test/ejs_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,22 +231,22 @@ test("helpers", function() {
test('list helper', function(){

var text = "<% list(todos, function(todo){ %><div><%= todo.name %></div><% }) %>";
var Todos = new can.Observe.List([
var todos = new can.Observe.List([
{id: 1, name: 'Dishes'}
]),
compiled = new can.EJS({text: text}).render({todos: Todos}),
compiled = new can.EJS({text: text}).render({todos: todos}),
div = document.createElement('div');

div.appendChild(can.view.frag(compiled))
equals(div.getElementsByTagName('div').length, 1, '1 item in list')

Todos.push({id: 2, name: 'Laundry'})
todos.push({id: 2, name: 'Laundry'})
equals(div.getElementsByTagName('div').length, 2, '2 items in list')

Todos.splice(0, 2);
todos.splice(0, 2);
equals(div.getElementsByTagName('div').length, 0, '0 items in list')

Todos.push({id: 4, name: 'Pick up sticks'});
todos.push({id: 4, name: 'Pick up sticks'});
equals(div.getElementsByTagName('div').length, 1, '1 item in list again')

});
Expand Down
9 changes: 8 additions & 1 deletion view/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,15 @@ can.extend(can.view, {
nodeList = nodes;
can.view.registerNode(nodes);
} else {
can.remove( can.$(nodes) );
// Update node Array's to point to new nodes
// and then remove the old nodes.
// It has to be in this order for Mootools
// and IE because somehow, after an element
// is removed from the DOM, it loses its
// expando values.
var nodesToRemove = can.makeArray(nodes);
can.view.replace(nodes,newNodes);
can.remove( can.$(nodesToRemove) );
}
};
// nodes are the nodes that any updates will replace
Expand Down

0 comments on commit 6bb9c7d

Please sign in to comment.