Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

id in the overlayTableMarkup function could be found by using the .attr() function #209

Closed
ollie-iterators opened this issue Jun 7, 2023 · 3 comments
Labels

Comments

@ollie-iterators
Copy link

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.

@JohnCotterSSA
Copy link
Member

Thanks for looking into the code and making a recommendation.

This function already is a loop, and .id performs faster than jquery .attr()

@ollie-iterators
Copy link
Author

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)".

@ollie-iterators
Copy link
Author

ollie-iterators commented Jun 8, 2023

Difference in the code:

Original 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;

New Code

NOTE: markupOverlay would be moved out of the $("#ANDI508-testPage [data-tandi508-colindex]").each(function() area

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;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants