diff options
author | Phil Hughes <me@iamphill.com> | 2016-11-02 14:31:00 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2016-11-22 05:01:45 +0300 |
commit | af02f6ae9d500b0174cae106891b626d1dcae351 (patch) | |
tree | 597b20e70516086ad69d89ae83d51ac9fcfa1a76 /app/assets/javascripts/project.js | |
parent | 1a21fa26f6f4ef70157c58329687976fc3f555f7 (diff) |
Use cloneNode instead of createElement
Diffstat (limited to 'app/assets/javascripts/project.js')
-rw-r--r-- | app/assets/javascripts/project.js | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/app/assets/javascripts/project.js b/app/assets/javascripts/project.js index 78ab69206af..7ac070a9c37 100644 --- a/app/assets/javascripts/project.js +++ b/app/assets/javascripts/project.js @@ -54,6 +54,11 @@ }; Project.prototype.initRefSwitcher = function() { + var refListItem = document.createElement('li'), + refLink = document.createElement('a'); + + refLink.href = '#'; + return $('.js-project-refs-dropdown').each(function() { var $dropdown, selected; $dropdown = $(this); @@ -77,21 +82,24 @@ filterByText: true, fieldName: $dropdown.data('field-name'), renderRow: function(ref) { - var li = document.createElement('li'); + var li = refListItem.cloneNode(false); if (ref.header != null) { li.className = 'dropdown-header'; li.textContent = ref.header; } else { - var link = document.createElement('a'); - link.href = '#'; - link.className = ref.name === selected ? 'is-active' : ''; + var link = refLink.cloneNode(false); + + if (ref.name === selected) { + link.className = 'is-active'; + } + link.textContent = ref.name; link.dataset.ref = ref.name; li.appendChild(link); } - + return li; }, id: function(obj, $el) { |