Skip to content

Commit

Permalink
Simplify code for <dom-repeat>'s sort and filter properties
Browse files Browse the repository at this point in the history
  • Loading branch information
MajorBreakfast committed Jan 25, 2018
1 parent 49eb17b commit 88cca86
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/elements/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,24 @@
return this.__dataHost._methodHost || this.__dataHost;
}

__sortChanged(sort) {
let methodHost = this.__getMethodHost();
this.__sortFn = sort && (typeof sort == 'function' ? sort :
function() { return methodHost[sort].apply(methodHost, arguments); });
if (this.items) {
this.__debounceRender(this.__render);
__functionFromPropertyValue(functionOrMethodName) {
if (typeof functionOrMethodName === 'string') {
let methodName = functionOrMethodName;
let obj = this.__getMethodHost();
return function() { return obj[methodName].apply(obj, arguments); };
}

return functionOrMethodName;
}

__sortChanged(sort) {
this.__sortFn = this.__functionFromPropertyValue(sort);
if (this.items) { this.__debounceRender(this.__render); }
}

__filterChanged(filter) {
let methodHost = this.__getMethodHost();
this.__filterFn = filter && (typeof filter == 'function' ? filter :
function() { return methodHost[filter].apply(methodHost, arguments); });
if (this.items) {
this.__debounceRender(this.__render);
}
this.__filterFn = this.__functionFromPropertyValue(filter);
if (this.items) { this.__debounceRender(this.__render); }
}

__computeFrameTime(rate) {
Expand Down

0 comments on commit 88cca86

Please sign in to comment.