Commit e76e1e80 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Improve glDropdown rendering performance

Return jQuery element instead of HTML for renderRow for labels select
parent bf0b7927
...@@ -656,23 +656,7 @@ GitLabDropdown = (function() { ...@@ -656,23 +656,7 @@ GitLabDropdown = (function() {
if (this.options.renderMenu) { if (this.options.renderMenu) {
return this.options.renderMenu(html); return this.options.renderMenu(html);
} else { } else {
var ul = document.createElement('ul'); return $('<ul>').append(html);
for (var i = 0; i < html.length; i += 1) {
var el = html[i];
if (el instanceof $) {
el = el.get(0);
}
if (typeof el === 'string') {
ul.innerHTML += el;
} else {
ul.appendChild(el);
}
}
return ul;
} }
}; };
......
...@@ -266,9 +266,10 @@ export default class LabelsSelect { ...@@ -266,9 +266,10 @@ export default class LabelsSelect {
selectedClass.push('label-item'); selectedClass.push('label-item');
$a.attr('data-label-id', label.id); $a.attr('data-label-id', label.id);
} }
$a.addClass(selectedClass.join(' ')).html(`${colorEl} ${_.escape(label.title)}`); $a.addClass(selectedClass.join(' ')).html(`${colorEl} ${_.escape(label.title)}`);
// Return generated html
return $li.html($a).prop('outerHTML'); return $li.html($a);
}, },
search: { search: {
fields: ['title'], fields: ['title'],
......
---
title: Improve label select rendering
merge_request: 25281
author:
type: performance
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment