Closed ollie-iterators closed 1 year ago
Thanks for looking into the code and making a recommendation.
This function already is a loop, and .id performs faster than jquery .attr()
I'm talking about "AndiOverlay.prototype.overlayTableMarkup" in line 1533. The for loop would replace the if statements: "if(role)", "if(id)", "if(headers)", and "if(scope)".
Difference in the code:
scope = $(this).attr("scope"); headers = $(this).attr("headers"); id = this.id; role = $(this).attr("role");
markupOverlay = $(this).prop("tagName").toLowerCase();
if(role) markupOverlay += " role=" + role; if(id) markupOverlay += " id=" + id; if(headers) markupOverlay += " headers=" + headers; if(scope) markupOverlay += " scope=" + scope;
var attributesToFind = ["scope", "headers", "id", "role"]; for (var a = 0; a < attributesToFind.length; a++) { var attributeValue = $(this).attr(attributesToFind[a]); if (attributeValue) { markupOverlay += attributesToFind[a] + "=" + attributeValue; } }
The id value in the overlayTableMarkup function could be found by using the .attr() function.
This would allow the code to be condensed to use a for loop with a list containing the attributes that are being looked for.