Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure getPrototypeOf will not crash on plugin options with no scopes #9431

Merged
merged 2 commits into from Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/core/core.config.js
Expand Up @@ -277,6 +277,9 @@ export default class Config {
});

const array = Array.from(scopes);
if (array.length === 0) {
array.push(Object.create(null));
}
if (keysCached.has(keyLists)) {
cache.set(keyLists, array);
}
Expand Down
17 changes: 17 additions & 0 deletions test/specs/core.controller.tests.js
Expand Up @@ -1707,6 +1707,23 @@ describe('Chart', function() {
'before-0', 'after-0'
]);
});

it('should not crash when accessing options of a blank inline plugin', function() {
var chart = window.acquireChart({
type: 'line',
data: {datasets: [{}]},
plugins: [{}],
});

function iterateOptions() {
for (const plugin of chart._plugins._init) {
// triggering bug https://github.com/chartjs/Chart.js/issues/9368
expect(Object.getPrototypeOf(plugin.options)).toBeNull();
}
}

expect(iterateOptions).not.toThrow();
});
});

describe('metasets', function() {
Expand Down