Skip to content

Commit

Permalink
skip unnecessary todo-item renders
Browse files Browse the repository at this point in the history
  • Loading branch information
pemrouz committed May 17, 2016
1 parent 9f4502c commit fd5125a
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 40 deletions.
21 changes: 18 additions & 3 deletions time-travel-todo/dist/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function todo(_ref) {

o('todo-footer', { items: items, filter: filter });

o('todo-item', visible, null, 'todo-footer').each(ripple.draw);
o('todo-item', changed(visible), null, 'todo-footer');

function addItem() {
if (window.event.which != 13 || !this.value) return;
Expand All @@ -108,6 +108,19 @@ function todo(_ref) {

this.value = '';
}

function changed(items) {
var _o$node = o.node();

var change = _o$node.change;
var key;

return change.length !== 1 ? items : !change[0] ? items : change[0][0] !== 'items' ? items : !isFinite(key = change[0][1].key.split('.').shift()) ? items : items.map(function (_ref2) {
var completed = _ref2.completed;
var item = _ref2.item;
return { completed: completed, item: item, key: key };
});
}
}
},{}],8:[function(require,module,exports){
'use strict';
Expand Down Expand Up @@ -144,14 +157,16 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = item;
function item(d, i) {
if ('key' in d && d.key != --i) return;

var complete = function complete(el) {
return function (d) {
return update(i - 1 + '.completed', el.checked)(ripple('items'));
return update(i + '.completed', el.checked)(ripple('items'));
};
},
destroy = function destroy(el) {
return function (d) {
return remove(i - 1)(ripple('items'));
return remove(i)(ripple('items'));
};
},
o = once(this);
Expand Down
15 changes: 14 additions & 1 deletion time-travel-todo/dist/resources/todo-app/todo-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function todo(_ref) {

o('todo-footer', { items: items, filter: filter });

o('todo-item', visible, null, 'todo-footer').each(ripple.draw);
o('todo-item', changed(visible), null, 'todo-footer');

function addItem() {
if (window.event.which != 13 || !this.value) return;
Expand All @@ -27,4 +27,17 @@ function todo(_ref) {

this.value = '';
}

function changed(items) {
var _o$node = o.node();

var change = _o$node.change;
var key;

return change.length !== 1 ? items : !change[0] ? items : change[0][0] !== 'items' ? items : !isFinite(key = change[0][1].key.split('.').shift()) ? items : items.map(function (_ref2) {
var completed = _ref2.completed;
var item = _ref2.item;
return { completed: completed, item: item, key: key };
});
}
}
6 changes: 4 additions & 2 deletions time-travel-todo/dist/resources/todo-item/todo-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = item;
function item(d, i) {
if ('key' in d && d.key != --i) return;

var complete = function complete(el) {
return function (d) {
return update(i - 1 + '.completed', el.checked)(ripple('items'));
return update(i + '.completed', el.checked)(ripple('items'));
};
},
destroy = function destroy(el) {
return function (d) {
return remove(i - 1)(ripple('items'));
return remove(i)(ripple('items'));
};
},
o = once(this);
Expand Down
Loading

0 comments on commit fd5125a

Please sign in to comment.