Skip to content

Commit 098ced5

Browse files
committed
don't crawl in nested objs of valType:'any' attrs
1 parent db6f82d commit 098ced5

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/plot_api/validate.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,14 @@ function crawl(objIn, objOut, schema, list, base, path) {
161161
var valOut = objOut[k];
162162

163163
var nestedSchema = getNestedSchema(schema, k);
164-
var isInfoArray = (nestedSchema || {}).valType === 'info_array';
165-
var isColorscale = (nestedSchema || {}).valType === 'colorscale';
164+
var nestedValType = (nestedSchema || {}).valType;
165+
var isInfoArray = nestedValType === 'info_array';
166+
var isColorscale = nestedValType === 'colorscale';
166167
var items = (nestedSchema || {}).items;
167168

168169
if(!isInSchema(schema, k)) {
169170
list.push(format('schema', base, p));
170-
} else if(isPlainObject(valIn) && isPlainObject(valOut)) {
171+
} else if(isPlainObject(valIn) && isPlainObject(valOut) && nestedValType !== 'any') {
171172
crawl(valIn, valOut, nestedSchema, list, base, p);
172173
} else if(isInfoArray && isArray(valIn)) {
173174
if(valIn.length > valOut.length) {

test/jasmine/tests/validate_test.js

+23
Original file line numberDiff line numberDiff line change
@@ -640,4 +640,27 @@ describe('Plotly.validate', function() {
640640
}]);
641641
expect(out).toBeUndefined();
642642
});
643+
644+
it('should not attempt to crawl into nested objects of valType: \'any\' attributes', function() {
645+
var out = Plotly.validate([{
646+
mode: 'markers',
647+
x: ['a', 'b', 'c', 'a', 'b', 'c'],
648+
y: [1, 2, 3, 4, 5, 6],
649+
transforms: [{
650+
type: 'groupby',
651+
groups: ['a', 'b', 'c'],
652+
styles: [{
653+
target: 'a',
654+
value: {marker: {color: 'blue'}}
655+
}, {
656+
target: 'b',
657+
value: {marker: {color: 'red'}}
658+
}, {
659+
target: 'c',
660+
value: {marker: {color: 'black'}}
661+
}]
662+
}]
663+
}]);
664+
expect(out).toBeUndefined();
665+
});
643666
});

0 commit comments

Comments
 (0)