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); return this.fulfillAt(this.getTree(path.split('/')), path, query);
}, },
fulfillAt: function(tree, path, query) { fulfillAt: function(tree, path, query) {
var data, k, ref, sub, t; var data, have, k, sub, t;
data = this.fulfillLocal(path, query); data = this.fulfillLocal(path, query);
for (k in query) { have = _data[path];
t = query[k]; if (have != null) {
if (!QUERIES[k]) { for (k in query) {
continue; 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]) { if (query.kids && !have.EMPTY) {
throw TypeError("Wrong query type: " + k + ", '" + t + "'"); data.kids = {};
} for (k in tree) {
data[k] = (ref = _data[path]) != null ? ref[k] : void 0; sub = tree[k];
} data.kids[k] = this.fulfillAt(sub, path + "/" + k, query.kids);
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 (!_.isEmpty(data)) { if (!_.isEmpty(data)) {

View File

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