Commit af02f6ae authored by Phil Hughes's avatar Phil Hughes Committed by Jacob Schatz

Use cloneNode instead of createElement

parent 1a21fa26
...@@ -54,6 +54,11 @@ ...@@ -54,6 +54,11 @@
}; };
Project.prototype.initRefSwitcher = function() { Project.prototype.initRefSwitcher = function() {
var refListItem = document.createElement('li'),
refLink = document.createElement('a');
refLink.href = '#';
return $('.js-project-refs-dropdown').each(function() { return $('.js-project-refs-dropdown').each(function() {
var $dropdown, selected; var $dropdown, selected;
$dropdown = $(this); $dropdown = $(this);
...@@ -77,21 +82,24 @@ ...@@ -77,21 +82,24 @@
filterByText: true, filterByText: true,
fieldName: $dropdown.data('field-name'), fieldName: $dropdown.data('field-name'),
renderRow: function(ref) { renderRow: function(ref) {
var li = document.createElement('li'); var li = refListItem.cloneNode(false);
if (ref.header != null) { if (ref.header != null) {
li.className = 'dropdown-header'; li.className = 'dropdown-header';
li.textContent = ref.header; li.textContent = ref.header;
} else { } else {
var link = document.createElement('a'); var link = refLink.cloneNode(false);
link.href = '#';
link.className = ref.name === selected ? 'is-active' : ''; if (ref.name === selected) {
link.className = 'is-active';
}
link.textContent = ref.name; link.textContent = ref.name;
link.dataset.ref = ref.name; link.dataset.ref = ref.name;
li.appendChild(link); li.appendChild(link);
} }
return li; return li;
}, },
id: function(obj, $el) { id: function(obj, $el) {
......
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