actually fix EMPTY usage

This commit is contained in:
Anton Dyudin 2015-09-23 16:53:48 -07:00
parent b07f6fab02
commit cdad444127
2 changed files with 27 additions and 22 deletions

View File

@ -1693,23 +1693,26 @@ TreeStore = _.extend(EventEmitter.prototype, {
return this.fulfillAt(this.getTree(path.split('/')), path, query);
},
fulfillAt: function(tree, path, query) {
var data, k, ref, sub, t;
var data, have, k, sub, t;
data = this.fulfillLocal(path, query);
for (k in query) {
t = query[k];
if (!QUERIES[k]) {
continue;
have = _data[path];
if (have != null) {
for (k in query) {
t = query[k];
if (!QUERIES[k]) {
continue;
}
if (t !== QUERIES[k]) {
throw TypeError("Wrong query type: " + k + ", '" + t + "'");
}
data[k] = have[k];
}
if (t !== QUERIES[k]) {
throw TypeError("Wrong query type: " + k + ", '" + t + "'");
}
data[k] = (ref = _data[path]) != null ? ref[k] : void 0;
}
if (query.kids && !_data[path].EMPTY) {
data.kids = {};
for (k in tree) {
sub = tree[k];
data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids);
if (query.kids && !have.EMPTY) {
data.kids = {};
for (k in tree) {
sub = tree[k];
data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids);
}
}
}
if (!_.isEmpty(data)) {

View File

@ -21,13 +21,15 @@ TreeStore = _.extend EventEmitter.prototype, {
fulfill: (path,query) -> @fulfillAt (@getTree path.split '/'),path,query
fulfillAt: (tree,path,query)->
data = @fulfillLocal path, query
for k,t of query when QUERIES[k]
if t isnt QUERIES[k] then throw TypeError "Wrong query type: #{k}, '#{t}'"
data[k] = _data[path]?[k]
if query.kids and not _data[path]?.EMPTY
data.kids = {}
for k,sub of tree
data.kids[k] = @fulfillAt sub, path+"/"+k, query.kids
have = _data[path]
if have?
for k,t of query when QUERIES[k]
if t isnt QUERIES[k] then throw TypeError "Wrong query type: #{k}, '#{t}'"
data[k] = have[k]
if query.kids and not have.EMPTY
data.kids = {}
for k,sub of tree
data.kids[k] = @fulfillAt sub, path+"/"+k, query.kids
data unless _.isEmpty data
fulfillLocal: (path, query)->