Skip to content

editorial: refactor aria.js #2408

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

Merged
merged 8 commits into from
May 8, 2025
Merged

editorial: refactor aria.js #2408

merged 8 commits into from
May 8, 2025

Conversation

pkra
Copy link
Member

@pkra pkra commented Jan 3, 2025

Part of #2230

Partially moved from w3c/aria-common#106 at caf8e9e

From the original PR:

Much work to be done.

  • add a very simple test
    • test.sh runs respec on ARIA before/after applying aria.js changes and diffs the two results
  • rough goals
    • clarify (e.g., switch to const/let, replace reused variable names with unique ones)
    • simplify (e.g., loops over querySelectorAll, use sets instead of filtering)
    • revise HTML string creation
    • extract loops
  • steps
    • pdef, sdef loop
    • generating HTML for indices of (global) states&properties as well as role=roletype
    • rdef loop
    • roleInfo loop
    • propList loop
    • generate HTML for role-related indices, sub-Roles
    • clean-up
  • continuation
    • rewrite subRoles code

Preview | Diff

@pkra pkra requested a review from spectranaut January 3, 2025 16:12
Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for wai-aria ready!

Name Link
🔨 Latest commit 555a28a
🔍 Latest deploy log https://app.netlify.com/sites/wai-aria/deploys/67f4d4405c2de30008320d90
😎 Deploy Preview https://deploy-preview-2408--wai-aria.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@pkra pkra added Agenda-Editors editorial a change to an example, note, spelling, grammar, or is related to publishing or the repo labels Jan 3, 2025
@pkra pkra added this to the 2025 milestone Jan 3, 2025
pkra added 2 commits March 17, 2025 12:29
Copies the proposed refactor from
w3c/aria-common#106
at caf8e9e
The PR has many separate commits for easier review.
Copies from
w3c/aria-common#106
at caf8e9e
The PR has many separate commits for easier review.
@pkra pkra force-pushed the ariaCommonIssue104 branch from 717ecc5 to d167788 Compare March 17, 2025 11:46
// if we are in a div, convert that div to a section
// TODO:
// a) seems to be always the case.
// b) Why don't we author the spec this way?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copied from w3c/aria-common#106 (comment)

Seems like we should. Anything that is not generated should just be in the static html. It's odd because this container has id=<attributename> on it for the url fragment, which probably should be generated, since it is the same as the pdef/sdef

const itemEntry = propList[title];
const dRef = item.nextElementSibling;
dRef.id = "desc-" + title; // TODO: too much of a side-effect?
dRef.setAttribute("role", "definition"); // TODO: ditto?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From w3c/aria-common#106 (comment)

this kind of stuff is a little weird to be adding here, it's not generated, it should just be in the html, it seems.


pdefsAndsdefs.forEach(populatePropList.bind(null, propList));
pdefsAndsdefs.forEach(populateGlobalSP.bind(null, propList, globalSP));
pdefsAndsdefs.forEach(generateHTMLStatesAndProperties.bind(null, propList));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From w3c/aria-common#106 (comment)

Each of these new function names could maybe follow a bit better of conventions... my top preference is at at least to rename any function that changes or produces html to have the prefix render..., and to describe specifically what it is creating -- like, renderStatesAndPropertiesHeadings instead of generateHTMLStatesAndProperties.

Also, related, I guess the "populate" is fine, but I might use a word like build... for anything that is just producing a data structure. Like buildPropList and buildGlobalStatesAndPropertiesList and wherever else data is just being mined from the html and then rearranged.

Also.... I know you are reusing variable names, but personally I would use no short hands -- so, "buildStateAndPropertyList" instead of "buildPropList". I guess "pdefs" and "sdefs" etc are ok, considering they are using in our spec.

but right now I still don't really understand why there is a globalSP and propList and the difference between these two things.. could they somehow be names a bit more clearly? Or are you trying to reuse these original names to make it easier to compare to the original script?

applicabilityText ===
"All elements of the base markup except for some roles or elements that prohibit its use";
const isDeprecated =
applicabilityText === "Use as a global deprecated in ARIA 1.2";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From w3c/aria-common#106 (comment)

I see, this is awful. Definitely, it makes more sense to start with a JSON object rather than looking for this text..

@pkra
Copy link
Member Author

pkra commented Mar 21, 2025

After the individual comments above, here's the closing comment from @spectranaut's review at w3c/aria-common#106 (review)

Ok Peter I took another crack at going over this -- I wonder how much you would be interested in renaming functions or variables in this PR? :)

@pkra
Copy link
Member Author

pkra commented Mar 21, 2025

I wonder how much you would be interested in renaming functions or variables in this PR? :)

I'm interested and I will try to get to this before the editors' call next week. (fingers crossed)

pkra and others added 3 commits March 26, 2025 09:42
Following reviewer comments
- render***: (primarily) generates HTML
- build***: (primarily) extracts data for rendering & roleInfo.js
- a few comments added or tweaked

Respec output with only expected changes.
@pkra pkra marked this pull request as ready for review March 26, 2025 10:37
@spectranaut
Copy link
Contributor

whoo!! I'll take a look tomorrow!

@spectranaut
Copy link
Contributor

Ok @pkra -- what do you think should be the goal here? How close of a review do you want at this stage?

Should we just merge this, as an intermediate step, then decide how to clean up more in the future? I'm fine with merging it as is without a close review, as it's just clean up and the spec is the same.

@pkra
Copy link
Member Author

pkra commented Mar 28, 2025

Should we just merge this, as an intermediate step, then decide how to clean up more in the future?

That would be my suggestion. That way, we can start fixing the bugs we already know about (cf. the editors' board's "blocked" column). And of course we should continue to refactor it (incl. changing the spec to simplify the post-processing).

I'm fine with merging it as is without a close review, as it's just clean up and the spec is the same.

I did my best to test that, diffing local respec builds before/after. The local respec builds would always fail to find the funders.html include so I checked against the gh-pages branch just now, too.

@pkra pkra mentioned this pull request Mar 28, 2025
15 tasks
@pkra
Copy link
Member Author

pkra commented Mar 28, 2025

I've moved the TODOs from the top card to #2501

@pkra pkra merged commit b085915 into main May 8, 2025
7 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in ARIA Editors May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial a change to an example, note, spelling, grammar, or is related to publishing or the repo
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants