-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
fix(files): Move aria-label for favorite icon from span to icon #41953
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
Conversation
|
/backport to stable28 |
c6bce33 to
164fe37
Compare
Signed-off-by: Ferdinand Thiessen <[email protected]>
Signed-off-by: Ferdinand Thiessen <[email protected]>
164fe37 to
22b1c86
Compare
|
/backport f79a1ad to stable28 |
| // MDI default viewbox is "0 0 24 24" but we add a stroke of 10px so we must adjust it | ||
| const el = this.$el.querySelector('svg') | ||
| el.setAttribute('viewBox', '-4 -4 30 30') | ||
| el?.setAttribute?.('viewBox', '-4 -4 30 30') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, why add optional chaining here? Is it possible that there would be no SVG, or that the SVG element would not have the setAttribute method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
querySelector returns Element | undefined so for defensive programming either check and throw an error or use optional chaining. Otherwise at least casting to SvgElement is required.
But doing non of those results in type errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
querySelector returns Element | undefined
But we select an SVG element here, and we at least know that there is the setAttribute method. No chance el.setAttribute would be undefined. If that was only for TypeScript, IMO, we should use !. or as to fix TS error. (Otherwise, there is an unneeded check in a bundle and runtime).
In theory querySelector could return undefined here, but it would mean that something has changed in <NcIconSvgWrapper> and ?. would hide the issue instead of exposing it.
Summary
Move the label from the span to the icon itself
Checklist