mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 14:35:27 +00:00
list_render: Remove support for jQuery items.
All of our widgets now use templates to turn items into HTML strings, so we can simplify the code.
This commit is contained in:
@@ -109,30 +109,17 @@ exports.create = function ($container, list, opts) {
|
|||||||
const finish = blueslip.start_timing('list_render ' + opts.name);
|
const finish = blueslip.start_timing('list_render ' + opts.name);
|
||||||
let html = "";
|
let html = "";
|
||||||
for (const item of slice) {
|
for (const item of slice) {
|
||||||
let _item = opts.modifier(item);
|
const s = opts.modifier(item);
|
||||||
|
|
||||||
// if valid jQuery selection, attempt to grab all elements within
|
if (typeof s !== 'string') {
|
||||||
// and string them together into a giant outerHTML fragment.
|
blueslip.error('List item is not a string: ' + s);
|
||||||
if (_item.constructor === jQuery) {
|
continue;
|
||||||
_item = (function ($nodes) {
|
|
||||||
let html = "";
|
|
||||||
$nodes.each(function () {
|
|
||||||
if (this.nodeType === 1) {
|
|
||||||
html += this.outerHTML;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}(_item));
|
|
||||||
}
|
|
||||||
|
|
||||||
// if is a valid element, get the outerHTML.
|
|
||||||
if (_item instanceof Element) {
|
|
||||||
_item = _item.outerHTML;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// append the HTML or nothing if corrupt (null, undef, etc.).
|
// append the HTML or nothing if corrupt (null, undef, etc.).
|
||||||
html += _item || "";
|
if (s) {
|
||||||
|
html += s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
|||||||
Reference in New Issue
Block a user