mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
Reuse the existing visible comment data and escaped title attribute. Keep the localized count for multiple or empty comments. Cover count fallback and plain-text handling with Node tests, and verify admin/read-only rendering and private-board comment isolation in Chromium. Thanks to lonix1 and xet7 ! Fixes #1933,
10 lines
429 B
JavaScript
10 lines
429 B
JavaScript
// Reuse only the comments already visible to the caller. Render the returned
|
|
// string through a normal escaped title attribute, never as HTML.
|
|
export function commentBadgeTitle(comments, countTitle) {
|
|
const visible = Array.isArray(comments) ? comments : [];
|
|
if (visible.length === 1 && typeof visible[0]?.text === 'string' && visible[0].text.trim()) {
|
|
return visible[0].text;
|
|
}
|
|
return countTitle(visible.length);
|
|
}
|