From fbbb9a9b1376d3c2a65efc5b2dc488057a2bd867 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 30 Dec 2018 02:43:23 +0300 Subject: [PATCH] shaved off some more general case complexity of the .toggle(..)/.tags(..) flow... Signed-off-by: Alex A. Naanou --- ui (gen4)/imagegrid/tags.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui (gen4)/imagegrid/tags.js b/ui (gen4)/imagegrid/tags.js index 25246255..b67529a9 100755 --- a/ui (gen4)/imagegrid/tags.js +++ b/ui (gen4)/imagegrid/tags.js @@ -569,6 +569,7 @@ var BaseTagsPrototype = { no_definitions = cmp cmp = null } + b = b instanceof Set ? [...b] : b // no given tags or multiple tags -> filter... if(b == null || b instanceof Array){ @@ -767,6 +768,7 @@ var BaseTagsPrototype = { var seen = new Set() var res = (quoted || root || base || b instanceof Array + || b instanceof Set || typeof(b) == typeof('str')) ? // b is given and a is an edge -> try a direct match... this.directMatch(...arguments) @@ -949,9 +951,10 @@ var BaseTagsPrototype = { // check if value is tagged by tags.., if(value && tags.length > 0){ tags = normalizeSplit(tags) - var u = this.tags(value) + var u = new Set(this.tags(value)) while(tags.length > 0){ - if(this.match(tags.shift(), u).length == 0){ + var t = tags.shift() + if(!u.has(t) && this.match(t, u).length == 0){ return false } } @@ -1158,6 +1161,8 @@ var BaseTagsPrototype = { // matching tags values off as expected but ignore toggling // tags on in which case null will be returned for the // corresponding position. + // NOTE: this will set all the tags on if at least one is off + // or off if all are on for each item... // // Toggle tag on for all values... // .toggle(tag, value, 'on') @@ -1213,8 +1218,6 @@ var BaseTagsPrototype = { // toggle each... : values // build the on/off lists... - // XXX this will either set all the tags on (if at least - // one is off) or off (if all are on) for each item... .reduce(function(res, v){ var state = that.tags(v, tag)