ltpitt
asked on
Improve / make more efficient a Javascript snippet
I wrote this Javascript snippet for a Polymer fronted and it works without issues.
Are there any ways that you could suggest to make it more efficient / shorter?
Are there any ways that you could suggest to make it more efficient / shorter?
var expandedItems = this.shadowRoot.querySelectorAll('expandable-item');
for (var i = 0; i < expandedItems.length; ++i) {
if (expandedItems[i].hasAttribute("expanded")){
expandedItems[i].getElementsByClassName("expandable-icon")[0].setAttribute("icon", "arrow:chevron-open-down");
} else {
expandedItems[i].getElementsByClassName("expandable-icon")[0].setAttribute("icon", "arrow:chevron-open-right");
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER