summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-07 17:15:19 -0500
committerGitHub <noreply@github.com>2023-03-07 17:15:19 -0500
commited25e094abfc93e83c6fecb5d82ce64d0e220717 (patch)
tree0785b912734f3de99946a181f56ae9df17a1bcee /web_src
parent10df304b2fcaaa931f1b966999c5b37aebefbea6 (diff)
downloadgitea-ed25e094abfc93e83c6fecb5d82ce64d0e220717.tar.gz
gitea-ed25e094abfc93e83c6fecb5d82ce64d0e220717.zip
Fix adding of empty class name (#23352) (#23360)
Backport #23352 This PR is to fix the error shown below. The reason is because [`class-name` prop](https://github.com/go-gitea/gitea/blob/main/web_src/js/components/ActionRunStatus.vue#L6) given to `svg` component has a space, and classList cannot add empty string. https://user-images.githubusercontent.com/17645053/223346720-c7f9de43-5e69-4ecf-93c0-90bf04090693.mov Co-authored-by: Hester Gong <hestergong@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/svg.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/web_src/js/svg.js b/web_src/js/svg.js
index 2132ad3120..6476f16bfb 100644
--- a/web_src/js/svg.js
+++ b/web_src/js/svg.js
@@ -80,7 +80,8 @@ export function svg(name, size = 16, className = '') {
const svgNode = document.firstChild;
if (size !== 16) svgNode.setAttribute('width', String(size));
if (size !== 16) svgNode.setAttribute('height', String(size));
- if (className) svgNode.classList.add(...className.split(/\s+/));
+ // filter array to remove empty string
+ if (className) svgNode.classList.add(...className.split(/\s+/).filter(Boolean));
return serializer.serializeToString(svgNode);
}