diff --git a/static/js/list_render.js b/static/js/list_render.js index 02a040c139..ef2a73a61a 100644 --- a/static/js/list_render.js +++ b/static/js/list_render.js @@ -4,6 +4,22 @@ const DEFAULTS = { instances: new Map(), }; + +// ---------------------------------------------------- +// This function describes (programatically) how to use +// the list_render widget. +// ---------------------------------------------------- + +exports.validate_opts = (opts) => { + if (opts.html_selector && typeof opts.html_selector !== 'function') { + // We have an html_selector, but it is not a function. + // This is a programming error. + blueslip.error('html_selector should be a function.'); + return false; + } + return true; +}; + exports.get_filtered_items = (value, list, opts) => { /* This is used by the main object (see `create`), @@ -110,6 +126,10 @@ exports.create = function ($container, list, opts) { return; } + if (!exports.validate_opts(opts)) { + return; + } + if (opts.name && DEFAULTS.instances.get(opts.name)) { // Clear event handlers for prior widget. const old_widget = DEFAULTS.instances.get(opts.name);