mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
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:
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
Reference in New Issue
Block a user