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

[SSR] aria-* attributes of dynamic null/undefined values render as strings #4788

Open
nolanlawson opened this issue Nov 6, 2024 · 3 comments

Comments

@nolanlawson
Copy link
Collaborator

<div aria-label={dynamic}></div>
<x-child aria-label={dynamic}></x-child>

As demonstrated in #4787, if dynamic is undefined, then this renders (in engine-server):

<div></div>
<x-child aria-activedescendant="undefined"></x-child>

And for null:

<div></div>
<x-child aria-activedescendant="null"></x-child>

This is inconsistent at best and wrong at worst. We should probably omit the attribute in both cases.

@wjhsf
Copy link
Contributor

wjhsf commented Nov 6, 2024

Is this specific to ARIA attributes? All of them, standard, or non-standard? Does it impact regular attributes, global HTML attributes, @api attributes?

@nolanlawson
Copy link
Collaborator Author

Is this specific to ARIA attributes?

Dunno. Worth testing HTML global attributes and data-foo as well.

All of them, standard, or non-standard?

In this case the attributes are purely being used as attributes, so "standard vs nonstandard" doesn't apply. E.g. we have aria-labelledby here as an attribute, not our nonstandard ariaLabelledBy property.

@api

This would be another good thing to add tests for. I don't believe it should matter, but you never know.

@nolanlawson
Copy link
Collaborator Author

BTW this is not terribly important because, unless you have an element with id="undefined" or id="null" somewhere, then the effective difference between rendering aria-labelledby="undefined" and not rendering it at all is zero.

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

No branches or pull requests

2 participants