From f188577a3b5473ba3b4d4ed2565b9871a0b2da13 Mon Sep 17 00:00:00 2001 From: David Cook Date: Wed, 29 Oct 2025 05:24:12 +0000 Subject: [PATCH] Bug 41128: Only use data rating if it's available This patch prevents span elements being filled with "undefined" which are then shown to screen readers and print output. Test plan: 0. Apply the patch 1. Enable the following system preference: OpacStarRatings (results, details, and patron). 2. Check out an item to a user you can log in as (e.g. koha user) 3. Go to /cgi-bin/koha/opac-user.pl in the OPAC 4. Click "Print" on the toolbar above the summary table 5. Note that 5 occurrences of "undefined" do not appear next to the title in the print output Signed-off-by: Owen Leonard Signed-off-by: Paul Derscheid --- koha-tmpl/opac-tmpl/bootstrap/js/ratings.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js index 40ff854071e..1ee9c8de4a4 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/ratings.js @@ -70,7 +70,11 @@ $(document).ready(function () { $(this).replaceWith(span); } else { var data_rating = $(this).attr("data-rating-value"); - $(this).append('' + data_rating + ""); + if (data_rating) { + $(this).append( + '' + data_rating + "" + ); + } } }); }); -- 2.39.5