Open mikhail-shipaev opened 2 months ago
Thanks for the report. Does the issue you describe exist when jQuery UI 1.12.1 is used or only with jQuery UI 1.13.0 or newer?
Hello Michał,
I believe that the issue doesn’t show up in jQuery UI 1.12.1
This is because in 1.12.1 the content of item.value is being passed to $.trim() function that forgives when is called with non-string argument and doesn’t throw an exception.
Below is the relevant fragment of code of 1.12.1:
// Announce
the value in the liveRegion
label =
ui.item.attr( "aria-label" ) || item.value;
if ( label
&& $.trim( label ).length ) {
this.liveRegion.children().hide();
In jQuery UI 1.13.0 on the contrary this non-string values are being passed to String.prototype.trim() function which is only expects string argument and throws an exception is it’s not a string.
Below is the relevant code from 1.13.3:
// Announce
the value in the liveRegion
label =
ui.item.attr( "aria-label" ) || item.value;
if ( label
&& String.prototype.trim.call( label ).length ) {
Best regards,
Michael Shipaev
From: Michał Gołębiowski-Owczarek @.> Sent: Friday, August 23, 2024 6:41 PM To: jquery/jquery-ui @.> Cc: mikhail-shipaev @.>; Author < @.> Subject: Re: [jquery/jquery-ui] Autocomplete widget should use bound item.label property as a fallback for empty aria-label. (Issue #2282)
Thanks for the report. Does the issue you describe exist when jQuery UI 1.12.1 is used or only with jQuery UI 1.13.0 or newer?
— Reply to this email directly, view it on GitHub https://github.com/jquery/jquery-ui/issues/2282#issuecomment-2307438284, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKUYISI2S26KSEJMLLIPAM3ZS5QZFAVCNFSM6AAAAABM22L2CSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBXGQZTQMRYGQ . You are receiving this because you authored the thread.Message ID: < @.***>
https://github.com/jquery/jquery-ui/blob/54f96eea31b21d9ecb00912261df3e5aaebf8cce/ui/widgets/autocomplete.js#L256-L258
When li element in the dropdown list has an empty "aria-label" attribute current implementation fallbacks to using bound item.value for aria-label.
It'd be more logical using item.label for fallback instead. Additionally this may lead to js exception when item.value is not of "string" type because in the next line it's passed to String.prototype.trim function that accepts only string arguments.