Skip to content

Commit f79cea9

Browse files
committed
Attempt at plotly#796
1 parent 626348f commit f79cea9

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

inst/htmlwidgets/plotly.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -563,19 +563,28 @@ TraceManager.prototype.updateSelection = function(group, keys) {
563563

564564
// find matches for nested keys
565565
function findNestedMatches(haystack, needleSet) {
566-
var matches = [];
567-
// ensure both haystack and needleset are an array of an arrays
568-
for (var i = 0; i < haystack.length; i++) {
569-
if (!Array.isArray(haystack[i])) {
570-
haystack[i] = [haystack[i]];
566+
567+
// ensure haystack is an array of an arrays
568+
if (!Array.isArray(haystack)) {
569+
haystack = [haystack];
570+
for (var i = 0; i < haystack.length; i++) {
571+
if (!Array.isArray(haystack[i])) {
572+
haystack[i] = [haystack[i]];
573+
}
571574
}
572575
}
573-
for (var i = 0; i < needleSet.length; i++) {
574-
if (!Array.isArray(needleSet[i])) {
575-
needleSet[i] = [needleSet[i]];
576+
// ensure needleSet is an array of an arrays
577+
if (!Array.isArray(needleSet)) {
578+
needleSet = [needleSet];
579+
for (var i = 0; i < needleSet.length; i++) {
580+
if (!Array.isArray(needleSet[i])) {
581+
needleSet[i] = [needleSet[i]];
582+
}
576583
}
577584
}
578-
// return a match if a haystack element is a subset of a
585+
586+
// return a match if a haystack array is a superset of a needleset array
587+
var matches = [];
579588
for (var i = 0; i < haystack.length; i++) {
580589
var hay = haystack[i];
581590
for (var j = 0; j < needleSet.length; j++) {

0 commit comments

Comments
 (0)