}
const readKey = (prefix, name) => prefix ? prefix + _capitalize(name) : name;
-const needsSubResolver = (prop, value) => isObject(value);
+const needsSubResolver = (prop, value) => isObject(value) && prop !== 'adapters';
function _cached(target, prop, resolve) {
let value = target[prop]; // cached value
// The fallback will resume to that new scope.
return fallback;
}
- } else if (scope === false && key !== 'fill') {
- // Fallback to `false` results to `false`, expect for `fill`.
- // The special case (fill) should be handled through descriptors.
+ } else if (scope === false && defined(parentFallback) && key !== parentFallback) {
+ // Fallback to `false` results to `false`, when falling back to different key.
+ // For example `interaction` from `hover` or `plugins.tooltip` and `animation` from `animations`
return null;
}
}
const fallback = resolveFallback(resolver._fallback, prop, value);
const allScopes = [...parentScopes, ...rootScopes];
const set = new Set([value]);
- let key = prop;
- while (key !== false) {
- key = addScopes(set, allScopes, key, fallback);
- if (key === null) {
- return false;
- }
+ let key = addScopesFromKey(set, allScopes, prop, fallback || prop);
+ if (key === null) {
+ return false;
}
if (defined(fallback) && fallback !== prop) {
- const fallbackScopes = allScopes;
- key = fallback;
- while (key !== false) {
- key = addScopes(set, fallbackScopes, key, fallback);
+ key = addScopesFromKey(set, allScopes, fallback, key);
+ if (key === null) {
+ return false;
}
}
return _createResolver([...set], [''], rootScopes, fallback);
}
+function addScopesFromKey(set, allScopes, key, fallback) {
+ while (key) {
+ key = addScopes(set, allScopes, key, fallback);
+ }
+ return key;
+}
function _resolveWithPrefixes(prop, prefixes, scopes, proxy) {
let value;
Chart.defaults.borderColor = oldColor;
});
+ it('should read parsing from options when default is false', function() {
+ const originalDefault = Chart.defaults.parsing;
+ Chart.defaults.parsing = false;
+
+ var chart = acquireChart({
+ type: 'line',
+ data: {
+ datasets: [{
+ data: [{t: 1, y: 0}]
+ }]
+ },
+ options: {
+ parsing: {
+ xAxisKey: 't'
+ }
+ }
+ });
+
+ var meta = chart.getDatasetMeta(0);
+ expect(meta.data[0].x).not.toBeNaN();
+
+ // Reset old shared state
+ Chart.defaults.parsing = originalDefault;
+ });
+
describe('resolveDataElementOptions', function() {
it('should cache options when possible', function() {
const chart = acquireChart({
expect('test' in opts).toBeFalse();
});
+ it('should not create proxy for adapters', function() {
+ const defaults = {
+ scales: {
+ time: {
+ adapters: {
+ date: {
+ locale: {
+ method: (arg) => arg === undefined ? 'ok' : 'fail'
+ }
+ }
+ }
+ }
+ }
+ };
+
+ const resolver = _createResolver([{}, defaults]);
+ const opts = _attachContext(resolver, {index: 1});
+ const fn = opts.scales.time.adapters.date.locale.method;
+ expect(typeof fn).toBe('function');
+ expect(fn()).toEqual('ok');
+ });
+
describe('_indexable and _scriptable', function() {
it('should default to true', function() {
const options = {