MCPcopy Create free account
hub / github.com/plotly/plotly.js / recurseIntoValObject

Function recurseIntoValObject

src/plot_api/plot_schema.js:335–379  ·  view source on GitHub ↗
(valObject, parts, i)

Source from the content-addressed store, hash-verified

333}
334
335function recurseIntoValObject(valObject, parts, i) {
336 if(!valObject) return false;
337
338 if(valObject._isLinkedToArray) {
339 // skip array index, abort if we try to dive into an array without an index
340 if(isIndex(parts[i])) i++;
341 else if(i < parts.length) return false;
342 }
343
344 // now recurse as far as we can. Occasionally we have an attribute
345 // setting an internal part below what's in the schema; just return
346 // the innermost schema item we find.
347 for(; i < parts.length; i++) {
348 var newValObject = valObject[parts[i]];
349 if(isPlainObject(newValObject)) valObject = newValObject;
350 else break;
351
352 if(i === parts.length - 1) break;
353
354 if(valObject._isLinkedToArray) {
355 i++;
356 if(!isIndex(parts[i])) return false;
357 } else if(valObject.valType === 'info_array') {
358 i++;
359 var index = parts[i];
360 if(!isIndex(index)) return false;
361
362 var items = valObject.items;
363 if(Array.isArray(items)) {
364 if(index >= items.length) return false;
365 if(valObject.dimensions === 2) {
366 i++;
367 if(parts.length === i) return valObject;
368 var index2 = parts[i];
369 if(!isIndex(index2)) return false;
370 valObject = items[index][index2];
371 } else valObject = items[index];
372 } else {
373 valObject = items;
374 }
375 }
376 }
377
378 return valObject;
379}
380
381// note: this is different from Lib.isIndex, this one doesn't accept numeric
382// strings, only actual numbers.

Callers 1

plot_schema.jsFile · 0.85

Calls 1

isIndexFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…