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

Added strict typings for ARIAMixin with literals #1840

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

DeepDoge
Copy link

@DeepDoge DeepDoge commented Nov 3, 2024

Added stricter typings for ARIAMixin with a fallback to also allow any other string. Also used ${bigint} and ${number} to type, integer and number only properties.

I wasn't sure if I should create a new enum type for each ARIA property, so I inlined them in the overrideType.

Fixes the issue: #1835

Copy link
Contributor

github-actions bot commented Nov 3, 2024

Thanks for the PR!

This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged.

@DeepDoge
Copy link
Author

DeepDoge commented Nov 3, 2024

@microsoft-github-policy-service agree

Copy link
Contributor

@saschanaz saschanaz left a comment

Choose a reason for hiding this comment

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

baselines/dom.generated.d.ts Show resolved Hide resolved
baselines/dom.generated.d.ts Show resolved Hide resolved
inputfiles/overridingTypes.jsonc Outdated Show resolved Hide resolved
"properties": {
"property": {
"ariaColCount": {
"overrideType": "`${bigint}` | \"\""
Copy link
Contributor

Choose a reason for hiding this comment

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

Does bigint have any difference than number when used here? Quickly tried but number doesn't reject huge number either.

Copy link
Author

@DeepDoge DeepDoge Nov 4, 2024

Choose a reason for hiding this comment

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

${bigint} only allows integers, ${number} also allows floats.
So based on what w3c says, I used ${bigint} for integer types and ${number} for number types.

Also I allowed empty string "" on these. Thinking people might use empty string instead of null.
But now since I'm also removing string & {} from enums, making them stricter. Should I also remove the empty string ""?

// "overrideType": ""
// }
"role": {
"overrideType": "\"toolbar\" | \"tooltip\" | \"feed\" | \"math\" | \"presentation\" | \"none\" | \"note\" | \"application\" | \"article\" | \"cell\" | \"columnheader\" | \"definition\" | \"directory\" | \"document\" | \"figure\" | \"group\" | \"heading\" | \"img\" | \"list\" | \"listitem\" | \"meter\" | \"row\" | \"rowgroup\" | \"rowheader\" | \"separator\" | \"table\" | \"term\" | \"associationlist\" | \"associationlistitemkey\" | \"associationlistitemvalue\" | \"blockquote\" | \"caption\" | \"code\" | \"deletion\" | \"emphasis\" | \"insertion\" | \"paragraph\" | \"strong\" | \"subscript\" | \"superscript\" | \"time\" | \"scrollbar\" | \"searchbox\" | \"separator\" | \"slider\" | \"spinbutton\" | \"switch\" | \"tab\" | \"tabpanel\" | \"treeitem\" | \"combobox\" | \"menu\" | \"menubar\" | \"tablist\" | \"tree\" | \"treegrid\" | \"banner\" | \"complementary\" | \"contentinfo\" | \"form\" | \"main\" | \"navigation\" | \"region\" | \"search\" | \"alert\" | \"log\" | \"marquee\" | \"status\" | \"timer\" | \"alertdialog\" | \"dialog\" | (string & {})"
Copy link
Contributor

Choose a reason for hiding this comment

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

Where did you get this list? Have you checked everything here has multiple implementation support?

- Remove commented items
- Remove `string & {}` from types
- Remove empty strings from number types
- Update and export roles as enum `ARIARole`
- Add type for `ariaInvalid`
- Add unit tests
@DeepDoge
Copy link
Author

DeepDoge commented Nov 4, 2024

Removed commented items. Removed string & {} from types, and empty string from number and integer types.
Updated roles based on W3C instead of MDN, filtered out deprecated and abstract ones.
Added type for ariaInvalid. MDN was missing documention for ariaInvalid, but has one for aria-invalid attribute. So I missed it as well since I was looking into Element API on MDN. ariaInvalid has full browser support already.

@DeepDoge
Copy link
Author

DeepDoge commented Nov 4, 2024

@saschanaz Should I include roles listed at https://www.w3.org/TR/dpub-aria-1.1/#role_definitions? Svelte includes them in [role] attribute.

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

Successfully merging this pull request may close these issues.

2 participants