Index: tools/turbolizer/selection.js |
diff --git a/tools/turbolizer/selection.js b/tools/turbolizer/selection.js |
index eb7a0b094faa379cad31a1d149d4d9334c4b56f7..e9c02dda9e70e4883ce133c29dd1751c94fe5b59 100644 |
--- a/tools/turbolizer/selection.js |
+++ b/tools/turbolizer/selection.js |
@@ -27,20 +27,29 @@ Selection.prototype.clear = function() { |
count = 0; |
-Selection.prototype.select = function(s, selected) { |
+Selection.prototype.select = function(s, isSelected) { |
var handler = this.handler; |
- if (this.selection.has(s) && !selected) { |
- handler.select([s], false); |
- this.selection.delete(s); |
- return; |
- } |
- |
- if (selected) { |
- this.selection.add(s); |
- this.selectionBase = s; |
- this.lastSelection = s; |
- handler.select(this.selection, selected); |
+ if (!(Symbol.iterator in Object(s))) { s = [s]; } |
+ if (isSelected) { |
+ let first = true; |
+ for (let i of s) { |
+ if (first) { |
+ this.selectionBase = i; |
+ this.lastSelection = i; |
+ first = false; |
+ } |
+ this.selection.add(i); |
+ } |
+ } else { |
+ let unselectSet = new Set(); |
+ for (let i of s) { |
+ if (this.selection.has(i)) { |
+ unselectSet.add(i); |
+ this.selection.delete(i); |
+ } |
+ } |
} |
+ handler.select(this.selection, isSelected); |
} |