Skip to content

Commit 6dc01d6

Browse files
committed
Make 'is simple binding' false for non-length-one arrays
1 parent 6d2f655 commit 6dc01d6

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/plots/command.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,15 +201,17 @@ exports.hasSimpleAPICommandBindings = function(gd, commandList, bindingsByValue)
201201
binding = bindings[0];
202202
var value = binding.value;
203203
if(Array.isArray(value)) {
204-
value = value[0];
204+
if(value.length === 1) {
205+
value = value[0];
206+
} else {
207+
return false;
208+
}
205209
}
206210
if(bindingsByValue) {
207211
bindingsByValue[value] = i;
208212
}
209213
}
210214

211-
if(i === n) return false;
212-
213215
return refBinding;
214216
};
215217

test/jasmine/tests/command_test.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ describe('Plots.hasSimpleAPICommandBindings', function() {
155155
args: [{'marker.color': 20}, [2, 1]]
156156
}]);
157157

158-
expect(isSimple).toEqual({
158+
// See https://github.com/plotly/plotly.js/issues/1169 for an example of where
159+
// this logic was a little too sophisticated. It's better to bail out and omit
160+
// functionality than to get it wrong.
161+
expect(isSimple).toEqual(false);
162+
163+
/* expect(isSimple).toEqual({
159164
type: 'data',
160165
prop: 'marker.color',
161166
traces: [ 1, 2 ],
162167
value: [ 10, 10 ]
163-
});
168+
});*/
164169
});
165170
});
166171

@@ -508,6 +513,14 @@ describe('component bindings', function() {
508513
}).catch(fail).then(done);
509514
});
510515

516+
it('udpates bound components when the value changes', function(done) {
517+
expect(gd.layout.sliders[0].active).toBe(0);
518+
519+
Plotly.restyle(gd, 'marker.color', 'ecru').then(function() {
520+
expect(gd.layout.sliders[0].active).toBe(0);
521+
}).catch(fail).then(done);
522+
});
523+
511524
it('udpates bound components when the computed value changes', function(done) {
512525
expect(gd.layout.sliders[0].active).toBe(0);
513526

0 commit comments

Comments
 (0)