mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 09:50:08 -04:00
Dedupe list-entry shared attributes
The `getSharedAttributes` method gathers all attributes, and [DOM tokens](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) in the `class` attribute not controlled by the module for re-applying in the `render` method. Because it gathered them for all items, many duplicates ended up being added to new items. Browser engines were tidying up the duplicates but we shouldn't be adding them in the first place.
This commit is contained in:
@@ -58,6 +58,7 @@
|
||||
getAttributesHTML = function (attrsByElm) {
|
||||
var attrStr = '',
|
||||
elmIdx = attrsByElm.length,
|
||||
existingAttributes = [],
|
||||
elmAttrs,
|
||||
attrIdx;
|
||||
|
||||
@@ -65,7 +66,11 @@
|
||||
elmAttrs = attrsByElm[elmIdx];
|
||||
attrIdx = elmAttrs.length;
|
||||
while (attrIdx--) {
|
||||
attrStr += attributeTemplate.render({ 'name': elmAttrs[attrIdx].name, 'value': elmAttrs[attrIdx].value });
|
||||
// prevent duplicates
|
||||
if ($.inArray(elmAttrs[attrIdx].name, existingAttributes) === -1) {
|
||||
attrStr += attributeTemplate.render({ 'name': elmAttrs[attrIdx].name, 'value': elmAttrs[attrIdx].value });
|
||||
existingAttributes.push(elmAttrs[attrIdx].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
return attrStr;
|
||||
|
||||
Reference in New Issue
Block a user