Skip to content

Commit 890a324

Browse files
committed
fix Plotly.validate with attributes that end in numbers
1 parent c2bcfe3 commit 890a324

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/plot_api/validate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
3838
* - {string} msg
3939
* error message (shown in console in logger config argument is enable)
4040
*/
41-
module.exports = function valiate(data, layout) {
41+
module.exports = function validate(data, layout) {
4242
var schema = PlotSchema.get();
4343
var errorList = [];
4444
var gd = {_context: Lib.extendFlat({}, dfltConfig)};
@@ -397,6 +397,8 @@ function isInSchema(schema, key) {
397397
}
398398

399399
function getNestedSchema(schema, key) {
400+
if(key in schema) return schema[key];
401+
400402
var parts = splitKey(key);
401403

402404
return schema[parts.keyMinusId];

test/image/mocks/shapes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"yaxis2":{"title":"category","range":[0,1],"domain":[0.6,1],"anchor":"x2","type":"category","showgrid":false,"zeroline":false,"showticklabels":false},
1919
"height":400,
2020
"width":800,
21-
"margin": {"l":20,"r":20,"top":10,"bottom":10,"pad":0},
21+
"margin": {"l":20,"r":20,"pad":0},
2222
"showlegend":false,
2323
"shapes":[
2424
{"layer":"below","xref":"paper","yref":"paper","x0":0,"x1":0.1,"y0":0,"y1":0.1},

test/jasmine/tests/validate_test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,4 +531,12 @@ describe('Plotly.validate', function() {
531531

532532
expect(out).toBeUndefined();
533533
});
534+
535+
it('should accept attributes that really end in a number', function() {
536+
// and not try to strip that number off!
537+
// eg x0, x1 in shapes
538+
var shapeMock = require('@mocks/shapes.json');
539+
var out = Plotly.validate(shapeMock.data, shapeMock.layout);
540+
expect(out).toBeUndefined();
541+
});
534542
});

0 commit comments

Comments
 (0)