-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: getAriaLabel can throw an exception when rendering form components #22678
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
Comments
@liamdebeasi , |
Thanks for the issue. Can you try the following dev build and let me know if it resolves the issue? Angular
React
Vue
Stencil/Vanilla JavaScript
|
@liamdebeasi , I tried the dev build with angular and it works fine. Thanks. |
Thanks for the issue. This has been resolved via #22680, and a fix will be available in an upcoming release of Ionic Framework.
I recommend creating a post on our forums for assistance with this: http://forum.ionicframework.com/ |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic version:
[x] 5.5.2
Current behavior:
If an element
id
attribute contains certain characters then form components (radio, checkbox, toggle) can fail to render and throw an exception.For example, if you render the following:
then the following error will occur:
Potential solution:
The following line of code in
getAriaLabel
withinhelpers.ts
causes the problem:The attribute value should be quoted to support spaces, periods and other reserved characters.
For example,
document.querySelector('label[for="a.b"]')
works anddocument.querySelector('label[for=a.b]')
fails.Note that the id could even contain a quote so it would need to be escaped as well.
Other related issues:
There are a couple of other less serious issues within the
getAriaLabel
function.If the label id contains certain characters (e.g. "a.b") then it will not be found.
This has less impact but could be fixed by using
document.getElementById
.Lastly, the function sets the id on the label element even if it already has a value.
It might be better to only set the id if it does not already have a value. This is not a very likely case but seems better to not overwrite specified values.
The text was updated successfully, but these errors were encountered: