list_render: Error if opts are missing.

The check here was too late, and it should
have given a blueslip error.  We obviously
don't expect these errors at runtime; this
is a convenience for developers creating
new widgets.
This commit is contained in:
Steve Howell
2020-04-24 13:38:16 +00:00
committed by showell
parent 5308f892d8
commit 059ad86967
2 changed files with 15 additions and 3 deletions

View File

@@ -453,3 +453,13 @@ run_test('clear_event_handlers', () => {
assert.equal(scroll_container.cleared, true);
assert.equal(filter_element.cleared, true);
});
run_test('errors', () => {
// We don't care about actual data for this test.
const list = 'stub';
const container = 'stub';
blueslip.expect('error', 'Need opts to create widget.');
list_render.create(container, list);
blueslip.reset();
});

View File

@@ -51,6 +51,11 @@ exports.validate_filter = (opts) => {
// list: The list of items to progressively append.
// opts: An object of random preferences.
exports.create = function ($container, list, opts) {
if (!opts) {
blueslip.error('Need opts to create widget.');
return;
}
if (opts.name && DEFAULTS.instances.get(opts.name)) {
// Clear event handlers for prior widget.
const old_widget = DEFAULTS.instances.get(opts.name);
@@ -68,9 +73,6 @@ exports.create = function ($container, list, opts) {
filter_value: '',
};
if (!opts) {
return;
}
exports.validate_filter(opts);
const widget = {};