MCPcopy
hub / github.com/chartjs/Chart.js / addScopes

Function addScopes

src/helpers/helpers.config.ts:309–333  ·  view source on GitHub ↗
(
  set: Set<AnyObject>,
  parentScopes: AnyObject[],
  key: ResolverObjectKey,
  parentFallback: ResolverObjectKey,
  value: unknown
)

Source from the content-addressed store, hash-verified

307 : typeof key === 'string' ? resolveObjectKey(parent, key) : undefined;
308
309function addScopes(
310 set: Set<AnyObject>,
311 parentScopes: AnyObject[],
312 key: ResolverObjectKey,
313 parentFallback: ResolverObjectKey,
314 value: unknown
315) {
316 for (const parent of parentScopes) {
317 const scope = getScope(key, parent);
318 if (scope) {
319 set.add(scope);
320 const fallback = resolveFallback(scope._fallback, key, value);
321 if (typeof fallback !== 'undefined' && fallback !== key && fallback !== parentFallback) {
322 // When we reach the descriptor that defines a new _fallback, return that.
323 // The fallback will resume to that new scope.
324 return fallback;
325 }
326 } else if (scope === false && typeof parentFallback !== 'undefined' && key !== parentFallback) {
327 // Fallback to `false` results to `false`, when falling back to different key.
328 // For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`
329 return null;
330 }
331 }
332 return false;
333}
334
335function createSubResolver(
336 parentScopes: AnyObject[],

Callers 1

addScopesFromKeyFunction · 0.85

Calls 3

resolveFallbackFunction · 0.85
getScopeFunction · 0.70
addMethod · 0.65

Tested by

no test coverage detected